From 4d3c27d026c1fe4283795b26d418a1f7e93ed077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Mon, 22 Apr 2024 13:49:30 +0200 Subject: [PATCH] [v1.27] fix(hetzner): hostname label is not considered The Node Group info we currently return does not include the `kubernetes.io/hostname` label, which is usually set on every node. This causes issues when the user has an unscheduled pod with a `topologySpreadConstraint` on `topologyKey: kubernetes.io/hostname`. cluster-autoscaler is unable to fulfill this constraint and does not scale up any of the node groups. Related to #6715 --- .../cloudprovider/hetzner/hetzner_node_group.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go b/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go index 8cac65c6c405..5818da61d924 100644 --- a/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go +++ b/cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go @@ -19,6 +19,7 @@ package hetzner import ( "context" "fmt" + "maps" "math/rand" "strings" "sync" @@ -222,10 +223,14 @@ func (n *hetznerNodeGroup) TemplateNodeInfo() (*schedulerframework.NodeInfo, err return nil, fmt.Errorf("failed to create resource list for node group %s error: %v", n.id, err) } + nodeName := newNodeName(n) + node := apiv1.Node{ ObjectMeta: metav1.ObjectMeta{ - Name: newNodeName(n), - Labels: map[string]string{}, + Name: nodeName, + Labels: map[string]string{ + apiv1.LabelHostname: nodeName, + }, }, Status: apiv1.NodeStatus{ Capacity: resourceList,