[EV-3914] Set the controller manager cache RESTMapper back to the DynamicRESTMapper (default changed on k8s upgrade) #2861
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 controller runtime adding this kubernetes-sigs/controller-runtime@b38c4a5 which changes how the cache builder and the controller cache options are combined.
Previously if the cache builders REST Mapper was nil, it would default to the controllers rest mapper, which defaults to the DynamicRESTMapper. This rest mapper is not a static mapper, it looks up types that were previously missing when consulted, like the Tier or Licence types.
With the commit mentioned, if the Mapper in the cache builder config is nil that code defaults it to the DiscoveryRESTMapper, which does not look up types that were previously missing. We use the cache builder here https://github.com/tigera/operator/blob/master/main.go#L232 to do some special things for tiers, so the upgrade from controller runtime 0.13 to 0.14 switched the mapper. This is why removing the custom cache fixes the issue, since it means the default is changed back to the DynamicRestMapper.
This should probably be fixed upstream, but for now we can just set the Mapper in the builder to the DynamicRESTMapper as I've done in this commit.
Description
For PR author
make gen-files
make gen-versions
For PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bug
if this is a bugfix.kind/enhancement
if this is a a new feature.enterprise
if this PR applies to Calico Enterprise only.