-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ensure the machineset label value is valid per K8s convention #69
Conversation
It uses fnv-1a to generate a non-zero, non-cryptographic hash to replace any invalid characters in the label value. Since the machineset label value is only used to establish pod affinity, the actual label value is considered opaque. Ref: https://github.com/kubernetes-sigs/cluster-api/blob/010af7f92f98ead971742d347d258a8786d5d57c/util/labels/format/helpers.go Signed-off-by: Ivan Sim <[email protected]>
@ibrokethecloud Let me know what you think of this. My first thought is to delete those default affinity/anti-affinity rules, to make it easier to reason about and avoid unintended side effects. E.g., I am not sure why we append the affinity term to both the affinity and anti-affinity sets. Won't the affinity always take precedence, given the order they are evaluated? Or AIUI, it might make sense to keep the pod anti-affinity across nodes based on the original PR's intention. Or if we need to keep them, this PR proposes a solution based on what CAPI has done to tackle the same issue. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. thanks for the fix.
Related issue: harvester/harvester#7467 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. With the test steps, I can get label like harvesterhci.io/machineSetName: hash_zRYvIw_z
on the VM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bk201 @ibrokethecloud let me know what the backport targets are. |
When user defined custom affinity/anti-affinity rules for VMs, additional
preferred
affinity/anti-affinity rules are added to ensure thevirt-launcher
pods don't land on the same node (by keying the rules off the node's hostname). Currently, there are no checks to ensure the generated label value in these rules adhered to the Kubernetes' labeling convention.This PR uses the same approach as CAPI to format and hash the label value. Since the machineset label value is only used to establish pod affinity, the actual (hashed or not) label value used is opaque.
EDIT: Issue at harvester/harvester#7467.