Repository navigation
Conversation
…ersion kyverno.io serves ClusterPolicy in v1 and v2beta1, but its preferred version v2 has no ClusterPolicy. qbec made each such version canonical for itself, and CanonicalResources() picked v1 or v2beta1 at random (Go map order). Listing through v2beta1 never matches objects declared as v1, so every ClusterPolicy became a deletion candidate in about half of diff/apply runs. Now all versions of such a kind share the highest version by Kubernetes version ordering (GA > beta > alpha), for ClusterPolicy that is v1. Fixes splunk#312
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
srv-gh-tools
added a commit
to splunk/cla-agreement
that referenced
this pull request
Oct 6, 2026
Author
|
I have read the Code of Conduct and I hereby accept the Terms |
This branch has not been deployed
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.
Fixes #312.
Problem
When a kind is missing from its group's preferred version, qbec falls back to making each version that serves the kind canonical for itself.
kyverno.iois the common case: the preferred versionv2has noClusterPolicy, which is served byv1andv2beta1.CanonicalResources()then returnsv1orv2beta1depending on Go map iteration order. Listing throughv2beta1never matches objects declared asv1, so in roughly half ofqbec diff/qbec applyruns everyClusterPolicybecomes a deletion candidate. That is the good-path/bad-path pair in #312:list objects: type=kyverno.io/v1, Kind=ClusterPolicyversustype=kyverno.io/v2beta1, Kind=ClusterPolicyfollowed by a spurious deletion.Change
In
internal/remote/k8smeta/meta.go, a kind that falls back now gets one canonical version shared by all of its versions: the highest by Kubernetes version ordering (version.CompareKubeAwareVersionStrings: GA > beta > alpha, then major and minor). ForClusterPolicythat isv1. Kinds that do exist in their group's preferred version are not affected.Testing
TestCanonicalKindMissingInPreferredVersionmodels thekyverno.iodiscovery. BothClusterPolicyversions resolve tov1;CleanupPolicy, which the preferred version does serve, stays onv2; andCanonicalResources()returnsv1across 100 calls. Onmainthe test fails:v2beta1is canonical for itself, and the listed version flips between calls. With this change it passes.make build,go vet ./...andaddlicense -checkare clean.go test ./...passes apart fromvm/internal/ds/helm3TestRunTemplate, which fails the same way onmainin my environment (the PodDisruptionBudget renders aspolicy/v1beta1), so it is unrelated. Integration tests were not run locally — no kind cluster here.