-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RESTMapper randomly returns API versions #3133
Comments
I can add that even after vendoring the RESTMapper from controller-runtime v0.19 in Flux, I see warnings about incorrect API versions being selected/preferred by Flux. Example from a test-bootstrap in an ephemeral cluster:
And all our |
To address the issue, do we need an option in the restmapper of controller-runtime to keep the preferred version info? |
We don't want to duplicate the complexity of the upstream restmapper regarding preferred version selection. Controller-Runtime itself has no use-case where the api version isn't known. The best compromise I can think of is to construct an upstream restmapper when someone calls one of the methods that select a version on our restmapper |
It turns out this isn't needed, I misremembered the related code, the server tells us what the preferred version is. I posted a fix for this issue in #3151 What confuses me a lot here though is that this issue definitely predates the introduction of aggregated discovery, backporting the testcase I added to 0.19 makes it fail the same way. @stefanprodan what makes you think this is related to aggregated discovery? From what I can tell this issue exists since the introduction of a truly lazy resmapper in v0.15 |
I assumed it's the aggregated discovery because we didn't had this issue in older versions of Flux using controller-runtime 0.19 and older. It may well be that the latest RESTMapper made the version flipping happen more often. I will test the fix and see if we can switch back. Thanks a lot for looking into this. |
After #2901 we are observing in Flux that the RESTMapper can not be used reliably to determine the preferred API version of a custom resource.
When calling
RESTMapping
for aGroupKind
without specified versions (this is whatkubernetes-sigs/cli-utils/pkg/kstatus
does here), the controller-runtime RESTMapper will randomly return deprecated versions as the preferred resource mapping.Given that the
RESTMapping
implementation picks the first mapping from the version array, it suggests that the controller-runtime RESTMapper using the Aggregated Discovery reorders the array or somehow it only contains a single recored even if in etcd the CRD has multiple versions.Logs from Flux kustomize-controller:
To fix this in Flux, we decided to vendor the RESTMapper from controller-runtime v0.19 in fluxcd/pkg#873.
The text was updated successfully, but these errors were encountered: