Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
env:
IMAGE_NAME: hetzner-cloud-controller-manager-staging
REGISTRY: ghcr.io/syself
Expand Down Expand Up @@ -47,13 +49,6 @@ jobs:
- name: Install Cosign
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0

- name: Setup Env
run: |
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)"
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV

- name: Build and push manager image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
id: docker_build_release
Expand All @@ -62,8 +57,6 @@ jobs:
context: .
file: ./images/hetzner-cloud-controller-manager/Dockerfile
push: true
build-args: |
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ jobs:
sudo mv ./bom /usr/local/bin/bom
sudo chmod +x /usr/local/bin/bom

- name: Setup Env
run: |
DOCKER_BUILD_LDFLAGS="$(hack/version.sh)"
echo 'DOCKER_BUILD_LDFLAGS<<EOF' >> $GITHUB_ENV
echo $DOCKER_BUILD_LDFLAGS >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV

- name: Build and push manager image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
id: docker_build_release
Expand All @@ -72,8 +65,6 @@ jobs:
context: .
file: ./images/hetzner-cloud-controller-manager/Dockerfile
push: true
build-args: |
LDFLAGS=${{ env.DOCKER_BUILD_LDFLAGS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Expand Down
90 changes: 0 additions & 90 deletions hack/version.sh

This file was deleted.

13 changes: 9 additions & 4 deletions hcloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ const (

var errMissingRobotCredentials = errors.New("missing robot credentials - cannot connect to robot API")

// providerVersion is set by the build process using -ldflags -X.
var providerVersion = "unknown"
func providerVersion() string {
info, ok := debug.ReadBuildInfo()
if !ok {
return "failed-to-get-version-info"
}
return info.Main.Version
}

type cloud struct {
hcloudClient *hcloud.Client
Expand Down Expand Up @@ -120,7 +125,7 @@ func newHcloudClient(rootDir string) (*hcloud.Client, error) {
}
opts := []hcloud.ClientOption{
hcloud.WithToken(token),
hcloud.WithApplication("hetzner-cloud-controller", providerVersion),
hcloud.WithApplication("hetzner-cloud-controller", providerVersion()),
}

// start metrics server if enabled (enabled by default)
Expand Down Expand Up @@ -214,7 +219,7 @@ func newCloud(_ io.Reader) (cloudprovider.Interface, error) {
return nil, fmt.Errorf("%s: %w", op, err)
}

klog.Infof("Hetzner Cloud k8s cloud controller %s started\n", providerVersion)
klog.Infof("Hetzner Cloud k8s cloud controller %s started\n", providerVersion())

lbOpsDefaults.DisableIPv6 = lbDisableIPv6

Expand Down
8 changes: 6 additions & 2 deletions hcloud/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/syself/hrobot-go/models"
corev1 "k8s.io/api/core/v1"
cloudprovider "k8s.io/cloud-provider"
"k8s.io/klog/v2"
)

type addressFamily int
Expand Down Expand Up @@ -129,10 +130,13 @@ func (i *instances) InstanceShutdown(ctx context.Context, node *corev1.Node) (bo
return false, nil
}

func (i *instances) InstanceMetadata(ctx context.Context, node *corev1.Node) (*cloudprovider.InstanceMetadata, error) {
func (i *instances) InstanceMetadata(ctx context.Context, node *corev1.Node) (metadata *cloudprovider.InstanceMetadata, reterr error) {
const op = "hcloud/instancesv2.InstanceMetadata"
metrics.OperationCalled.WithLabelValues(op).Inc()

defer func() {
klog.InfoS("InstanceMetadata", "node", node,
"InstanceMetadata", metadata, "err", reterr)
}()
hcloudServer, bmServer, isHCloudServer, err := i.lookupServer(ctx, node)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion images/hetzner-cloud-controller-manager/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . /src/hetzner-cloud-controller-manager
WORKDIR /src/hetzner-cloud-controller-manager
RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go/pkg \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
go build -mod=readonly -ldflags "${LDFLAGS} -extldflags '-static'" \
go build -mod=readonly -ldflags "-extldflags '-static'" \
-o manager main.go

FROM --platform=${BUILDPLATFORM} gcr.io/distroless/static:nonroot
Expand Down