Repository navigation
fix: react to label changes on pods again - #62
Merged
Merged
Conversation
The update filter had an empty `case *corev1.Pod:` ahead of the deployment case. Go type switches do not fall through, so every pod update returned false and the LabelChangedPredicate never applied to pods: labelling a running pod did not enqueue a reconcile, and removing the label did not trigger cleanup. The comment on the next case shows both kinds were meant to share it. Moved the filter into its own function so it can be tested without a manager.
Member
|
Wow, thanks! How could we have missed that previously, I am embarrassed, thank you for this excellent finding! 💙 Merging ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the update filter in
SetupWithManagerhas an emptycase *corev1.Pod:sitting in front of the deployment case:go type switches do not fall through, so a pod update matches the first case, runs nothing and falls out to
return false. theWatches(&corev1.Pod{}, watchHandler)two lines above therefore never fires on updates, andLabelChangedPredicateis dead for podsin practice: labelling a running pod so that a policy should now match it does not enqueue a reconcile, so the honeytoken never arrives. removing the label does not trigger cleanup either. the pod only gets picked up when something else happens to reconcile the policy
the comment on the deployment case says "For pods and deployments", so both kinds were meant to share that predicate
changes
merged the two cases, and did the same in
DeleteFuncwhere the shape is identical (harmless there, both branches return false, but it reads as the same mistake)moved the filter into
deceptionPolicyEventFilter()so it can be exercised without standing up a managertesting
three specs: a pod update that changes labels must pass, a deployment update that changes labels must pass, and a pod update that only changes status must still be dropped. that last one pins that this does not open the door to status churn
before the change the first spec fails, after it all three pass.
go test ./internal/... ./api/...is green with the envtest binaries frommake setup-envtest