Drift: NodeClass changes that do not show on the server never drift nodes #24

Open
opened 2026-10-27 21:46:32 +00:00 by mikluko · 0 comments
Owner

Changing a HCloudNodeClass does not drift the nodes made from it unless the change shows up on the running server. IsDrifted in pkg/cloudprovider/cloudprovider.go compares the server against the NodeClass for image ID, network, firewalls, server type, location and labels. Nothing else in the spec is compared, so an edit to any of these leaves existing nodes in place indefinitely:

  • bootstrap (beforeJoin, afterJoin, k0sVersion)
  • imageSelector: the recorded image ID is compared with the server's own image, which never changes, so a new selector is never detected
  • sshKeyIDs
  • enablePublicIPv4, enablePublicIPv6

Seen with 0.7.2: a sysctl added to beforeJoin reached new nodes only; existing NodeClaims never got a Drifted condition, and restarting the controller did not change that. The only way to apply it was to delete the NodeClaims by hand.

Most of these fields cannot be read back from the server, so comparing them against the server cannot work. The AWS provider solves the same problem with a hash: the NodeClass carries a hash of its spec (karpenter.k8s.aws/ec2nodeclass-hash, plus -hash-version), each NodeClaim is stamped with the hash at launch, and a mismatch is reported as NodeClassDrift. Fields that are checked against the server, or that change without needing new nodes, are excluded from the hash. The hash version lets a later change to the hashed fields avoid drifting every node at upgrade.


Written by an AI, reviewed by a human being.

Changing a `HCloudNodeClass` does not drift the nodes made from it unless the change shows up on the running server. `IsDrifted` in `pkg/cloudprovider/cloudprovider.go` compares the server against the NodeClass for image ID, network, firewalls, server type, location and labels. Nothing else in the spec is compared, so an edit to any of these leaves existing nodes in place indefinitely: - `bootstrap` (`beforeJoin`, `afterJoin`, `k0sVersion`) - `imageSelector`: the recorded image ID is compared with the server's own image, which never changes, so a new selector is never detected - `sshKeyIDs` - `enablePublicIPv4`, `enablePublicIPv6` Seen with 0.7.2: a sysctl added to `beforeJoin` reached new nodes only; existing NodeClaims never got a `Drifted` condition, and restarting the controller did not change that. The only way to apply it was to delete the NodeClaims by hand. Most of these fields cannot be read back from the server, so comparing them against the server cannot work. The AWS provider solves the same problem with a hash: the NodeClass carries a hash of its spec (`karpenter.k8s.aws/ec2nodeclass-hash`, plus `-hash-version`), each NodeClaim is stamped with the hash at launch, and a mismatch is reported as `NodeClassDrift`. Fields that are checked against the server, or that change without needing new nodes, are excluded from the hash. The hash version lets a later change to the hashed fields avoid drifting every node at upgrade. --- *Written by an AI, reviewed by a human being.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/karpenter-provider-hetzner#24
No description provided.