fix(controllers) expand TypeMeta population #4758
Closed
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.
What this PR does / why we need it:
Expands TypeMeta population (see earlier work). Predicting where we'll need this isn't always easy, so just stuffing it in every controller to be safe.
Add TypeMeta population to controller reference predicates.
Use a scheme-based helper to populate TypeMeta from a runtime.object instead of local GVK helpers or pre-defined objects.
Adds a test to confirm credentials update properly.
Which issue this PR fixes:
The added test breaks without the predicate changes. Updating a credential Secret (and presumably other referenced Secrets) after its initial load would not modify Kong configuration.
We add referent Secrets directly to the store from reference updaters, This populates the Secret initially, but future updates need to run through the Secret reconciler. The reconciler predicate was not building the reference key properly without TypeMeta and would never reconcile Secrets with references.
Special notes for your reviewer:
Ideally we could centralize TypeMeta injection, but I don't think we can (barring an upstream fix). I initially tried adding it to
store.Add()
, but this doesn't work for anything that might need it in the reconciler. AFAIK there's nowhere in controller-runtime that'd let us add a global preprocessing step.Trying to load manager configuration outside the manager results in a package import loop that I'm not particularly inclined to untangle. Removing feature gates for the scheme builder should be fine, since simply being aware of types doesn't do anything on its own.
This came out of research on #4672, but I'm still not fully sure why outdated CRDs trigger this. I suspect that the issue is somewhere in the reference builder store update since the predicate was never working, and that updater is seemingly the only way into the store that bypasses the reconciler.
Sadly, my reproduction steps (disable CRD installation in the test harness,
helm install wat kong/kong --version 2.13.1; helm delete
to get the old CRDs, install consumer group CRD and GWAPI) stopped reproducing the issue after I located this second store insert path, so I wasn't able to explore it fully.PR Readiness Checklist:
Complete these before marking the PR as
ready to review
:CHANGELOG.md
release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR