Skip to content

fix: omit labels/annotations keys when empty - #122

Open
bhavyaKhatri2703 wants to merge 1 commit into
kyverno:mainfrom
bhavyaKhatri2703:fix/empty-labels-annotations
Open

fix: omit labels/annotations keys when empty#122
bhavyaKhatri2703 wants to merge 1 commit into
kyverno:mainfrom
bhavyaKhatri2703:fix/empty-labels-annotations

Conversation

@bhavyaKhatri2703

Copy link
Copy Markdown

Explanation

Some Kyverno CRDs (the policies.kyverno.io ones) were rendering with empty labels: {} and annotations: {} in their YAML. Kubernetes doesn't store empty fields like that, so ArgoCD kept seeing a mismatch between the file and the live cluster and marked the app as permanently out of sync. This is a bug fix, no new behavior added.

Related issue

Fixes kyverno/kyverno#16764

Proposed Changes

The labels/annotations helpers in kyverno-api just dumped whatever was in .Values.labels/.Values.annotations straight into YAML, even when empty. An empty map still renders as the string "{}", so it showed up in output instead of nothing.

Fixed by wrapping both helpers in with, so they render nothing when values are empty, same as the crds subchart already does. Also updated all 11 affected CRD templates so the labels:/annotations: key itself gets skipped when there's nothing under it.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of
them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

This only fixes the empty map rendering as {} bug. The issue also suggests giving these CRDs the same standard app.kubernetes.io labels the crds subchart CRDs get by default.

Signed-off-by: bhavyaKhatri2703 <khatribhavya2703@gmail.com>
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.

[Bug] policies.kyverno.io CRDs render empty labels: {} and annotations: {} (chart 3.8.2)

1 participant