Skip to content

Commit 838ea22

Browse files
committed
Fixes to address code review comments
1 parent b2ead3b commit 838ea22

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

cluster-autoscaler/cloudprovider/hetzner/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The cluster autoscaler for Hetzner Cloud scales worker nodes.
88

99
`HCLOUD_CLOUD_INIT` Base64 encoded Cloud Init yaml with commands to join the cluster, Sample [examples/cloud-init.txt for (Kubernetes 1.20.1)](examples/cloud-init.txt)
1010

11-
`HCLOUD_IMAGE` Defaults to `ubuntu-20.04`, @see https://docs.hetzner.cloud/#images. You can also use an image ID here (e.g. `15512617`), or a label selector associated with a custom snapshot (e.g. `customized_ubuntu=true`).
11+
`HCLOUD_IMAGE` Defaults to `ubuntu-20.04`, @see https://docs.hetzner.cloud/#images. You can also use an image ID here (e.g. `15512617`), or a label selector associated with a custom snapshot (e.g. `customized_ubuntu=true`). The most recent snapshot will be used in the latter case.
1212

1313
`HCLOUD_NETWORK` Default empty , The name of the network that is used in the cluster , @see https://docs.hetzner.cloud/#networks
1414

cluster-autoscaler/cloudprovider/hetzner/hetzner_manager.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,16 @@ func newManager() (*hetznerManager, error) {
7272
// (e.g. "ubuntu-20.04"), or a label selector associated with an image
7373
// snapshot. In the latter case it will use the most recent snapshot.
7474
image, _, err := client.Image.Get(ctx, imageName)
75-
if err != nil || image == nil {
76-
labelSelector := strings.Split(imageName, "=")
77-
if len(labelSelector) != 2 {
78-
return nil, fmt.Errorf("unable to find image %s: invalid label selector", imageName)
79-
}
80-
75+
if err != nil {
76+
return nil, fmt.Errorf("unable to find image %s: %v", imageName, err)
77+
}
78+
if image == nil {
8179
images, err := client.Image.AllWithOpts(ctx, hcloud.ImageListOpts{
8280
Type: []hcloud.ImageType{hcloud.ImageTypeSnapshot},
8381
Status: []hcloud.ImageStatus{hcloud.ImageStatusAvailable},
8482
Sort: []string{"created:desc"},
8583
ListOpts: hcloud.ListOpts{
86-
LabelSelector: fmt.Sprintf("%s=%s", labelSelector[0], labelSelector[1]),
84+
LabelSelector: imageName,
8785
},
8886
})
8987

0 commit comments

Comments
 (0)