Repository navigation
Conversation
The node syncer merged taints by comparing the full JSON of each taint. When the host and the virtual node lifecycle controller both set node.kubernetes.io/unreachable, the two timeAdded values made two JSON strings, so both copies were kept. The apiserver requires taints to be unique by key and effect and rejected the update. The syncer retried that patch and stopped refreshing the virtual node. Merge on key and effect and keep the host copy, including value and timeAdded. Drop a virtual not-ready or unreachable taint when the host has none with that key. Treat a taint recorded in original-taints as removed when its key and effect are gone from the host, even if timeAdded differs. The annotation is still a JSON array of host taint JSON strings, and toleration filtering still runs after the merge. Signed-off-by: Prasad PL <ai@anoo.tech>
blacksoxx
left a comment
There was a problem hiding this comment.
Comment. The identity change is the right fix for #4130: with key and effect as the key, the second unreachable copy with a different timeAdded can no longer reach the apiserver. Verified at e744030 on current main: merge-tree clean, package tests, vet, gofmt and lint green, and the six new cases fail on main's translate.go except the virtual-only custom taint, which matches the body. Two notes inline, neither blocking.
| continue | ||
| } | ||
| // The host used to have this taint and has since removed it. | ||
| if _, ok := old[id]; ok { |
There was a problem hiding this comment.
[P3] With key and effect as the identity, a taint the tenant set on the virtual node with the same key and effect as a host taint is dropped the moment the host removes its copy, since the recorded original matches it too. The old string match only dropped an exact copy. Unavoidable with this identity, and following the host is the safer default; one line in the comment would stop the next reader from treating it as a bug.
There was a problem hiding this comment.
Thanks, agreed. Added a comment saying so in cc2329c.
|
|
||
| // dropVirtualLifecycleTaint reports whether a virtual node lifecycle taint should be | ||
| // omitted because the host node does not currently have that key. | ||
| func dropVirtualLifecycleTaint(key string, physicalKeys map[string]struct{}) bool { |
There was a problem hiding this comment.
[P3] The lifecycle check is by key only, so a host not-ready:NoSchedule keeps a virtual not-ready:NoExecute alive as a separate identity. That is what the old hasUnready check did for not-ready as well, so no change in behaviour, just noting it is deliberate.
There was a problem hiding this comment.
Yes, that's intentional. Added a comment noting it in cc2329c.
Signed-off-by: Prasad PL <ai@anoo.tech>
Fixes #4130
The node syncer merged host and virtual taints by comparing each taint's full JSON. When both the host and the virtual node lifecycle controller add
node.kubernetes.io/unreachable, thetimeAddedvalues differ, so both copies were kept. The apiserver then rejects the update with "taints must be unique by key and effect pair", and the virtual node stops getting refreshed.This change merges taints on key and effect and keeps the host copy, including its value and
timeAdded. A virtual not-ready or unreachable taint is dropped when the host has no taint with that key, and a taint recorded inoriginal-taintscounts as removed once its key and effect are gone from the host, even iftimeAddedchanged. The annotation format is the same, and toleration filtering still runs after the merge.I added six cases to
TestTranslateBackwards. Five of them fail on main and all pass with the fix.go test ./pkg/controllers/resources/nodes/, gofmt and go vet are clean.Note
Medium Risk
Changes how node taints are reconciled during sync, which affects scheduling and node readiness, but aligns with Kubernetes uniqueness rules and is covered by expanded unit tests.
Overview
Fixes duplicate lifecycle taints when syncing host nodes into the virtual cluster by replacing JSON string–based taint merging with merge by key + effect, where host taints always win (value and
timeAddedincluded).Virtual not-ready / unreachable taints are dropped if the host has no taint with that key; virtual taints that matched a previously recorded host taint (from
vcluster.loft.sh/original-taints) are dropped once the host removes that key/effect. The annotation format and post-merge toleration filtering are unchanged.TestTranslateBackwardsgains six cases covering mismatchedtimeAdded, virtual-only lifecycle taints, removed host taints, custom taints, and host-value precedence.Reviewed by Cursor Bugbot for commit cc2329c. Bugbot is set up for automated code reviews on this repo. Configure here.