Repository navigation
fix: keep annotations added after CreatePod when virtual-kubelet pushes a Pod's status - #148
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
virtual-kubelet pushes the provider's status with UpdateStatus on the provider's copy of the whole Pod, at resourceVersion "0". The pods/status endpoint resets only spec, deletionTimestamp and ownerReferences, so the push also writes that copy's labels and annotations. VK re-pushes its last copy as soon as it sees the Pod's annotations differ from it, so an annotation added since the copy was taken is removed within a second. A pod-deletion-cost, which tells a ReplicaSet scale-down which Pods to spare, is one such annotation. The PodClient handed to VK now sends UpdateStatus as a JSON patch that replaces /status on the status subresource. A JSON patch, not a merge patch, so a field the new status leaves out is cleared, as the update cleared it. The patch first tests the copy's UID, so a late push is refused by a Pod recreated under the same name, as an update was. Nebula's own annotations already reach the API server through patchMeta. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f43b772 to
5f73b13
Compare
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
/lgtm |
InftyAI-Agent
left a comment
There was a problem hiding this comment.
Approved: PR has both lgtm and approved labels
Problem
Nebula's virtual kubelet removes any annotation added to a Pod after CreatePod, within a second. For example, a controller's
controller.kubernetes.io/pod-deletion-costmark is lost, so a ReplicaSet scale-down can delete a busy Pod and keep an idle one. Pods on real kubelets keep their marks.The cause:
UpdateStatusat resourceVersion "0", so the write never conflicts (node/pod.go:241-245).Change
UpdateStatusas a JSON patch that replaces/statuson the status subresource. Labels and annotations others set stay.A JSON patch, not a merge patch, so a status field the provider empties is still cleared. Nebula's endpoint and instance-ID annotations reach the API server only through
patchMeta.Testing
New unit tests on client-go's fake clientset: a stale copy's status push keeps the annotation the live Pod gained and still updates (and clears) status fields; a push with an old UID is refused and leaves the recreated Pod alone.
go test ./pkg/... ./internal/...andmake lintpass.🤖 Generated with Claude Code