Skip to content

Commit

Permalink
[v1.30] fix(hetzner): hostname label is not considered
Browse files Browse the repository at this point in the history
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 kubernetes#6715
  • Loading branch information
apricote committed Apr 24, 2024
1 parent 6e3217d commit f23d5b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cluster-autoscaler/cloudprovider/hetzner/hetzner_node_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ package hetzner
import (
"context"
"fmt"
"maps"
"math/rand"
"strings"
"sync"
"time"

"maps"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -229,10 +228,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,
Expand Down

0 comments on commit f23d5b7

Please sign in to comment.