Skip to content

[v0.14] Fix namespace label equality check and nil map panic#5173

Merged
thardeck merged 2 commits into
release/v0.14from
v0.14_retain_relevant_labels
May 20, 2026
Merged

[v0.14] Fix namespace label equality check and nil map panic#5173
thardeck merged 2 commits into
release/v0.14from
v0.14_retain_relevant_labels

Conversation

@thardeck
Copy link
Copy Markdown
Collaborator

@thardeck thardeck commented May 20, 2026

Backports two fixes from #5156 to release/v0.14.

The previous reflect.DeepEqual comparison checked raw BundleDeployment options directly against ns.Labels, which always includes kubernetes.io/metadata.name and preserved pod-security labels. The check never held, causing an unnecessary updateNamespace call on every reconcile. Replace with maps.Clone + maps.Equal on the computed desired state.

maps.Clone returns nil when its source is nil, so when ns.Labels is nil and NamespaceLabels options are non-empty the pod-security check would panic. Add a nil guard matching the one already present for annotations.

thardeck added 2 commits May 20, 2026 11:08
Compare the computed desired state against the current namespace
labels and annotations instead of comparing raw options directly.
The previous reflect.DeepEqual check could never return true because
ns.Labels always includes kubernetes.io/metadata.name (and now also
preserved pod-security labels), causing an unnecessary updateNamespace
call on every reconcile even when no label changes were needed.
addLabelsFromOptions panics when ns.Labels is nil (maps.Clone returns
nil) and NamespaceLabels options are non-nil. Add the same nil guard
already present for annotations.

Update the function doc comment to reflect the actual label retention
rules: options labels, kubernetes.io/metadata.name, and existing
pod-security.kubernetes.io/* labels are preserved; pod-security labels
from options are ignored.
@thardeck thardeck self-assigned this May 20, 2026
@thardeck thardeck requested a review from a team as a code owner May 20, 2026 09:12
@thardeck thardeck changed the title [v0.12] Fix namespace label equality check and nil map panic [v0.14] Fix namespace label equality check and nil map panic May 20, 2026
@thardeck thardeck merged commit e423b88 into release/v0.14 May 20, 2026
37 of 39 checks passed
@thardeck thardeck deleted the v0.14_retain_relevant_labels branch May 20, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants