-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
pkg/restmapper,scaffold/cmd.go: override default restmapper #1329
pkg/restmapper,scaffold/cmd.go: override default restmapper #1329
Conversation
Looks good. To fix the tests, you need to update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just had a question on if this should be the default or not.
@@ -122,6 +123,7 @@ func main() { | |||
// Create a new Cmd to provide shared dependencies and start components | |||
mgr, err := manager.New(cfg, manager.Options{ | |||
Namespace: namespace, | |||
MapperProvider: restmapper.NewDynamicRESTMapper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we should make this an opt-in feature because missing there is no mechanism's in place to back off expensive reloads on every miss.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reasoned that it's better to be slow than wrong, by default, but I could go either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solly wanted a backoff upstream (controller-runtime); that's why I haven't just submitted this there already.
I guess the case where it would matter would be if you're waiting for another operator to create a bunch of objects of some CRD type. So then every now and then you do 50 GETs, to see if the 50 objects have been created. Which, with this code, could result in 50 restmapper reloads if the CRD hadn't been created yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably missing something but do we only incur the miss when the client/cache is used to CRUD an instance/CR of a newly created CRD whose mapping is not present in the DynamicRestMapper?
If so then I assume most likely this call(e.g GET) would be made inside the reconcile loop. If the DynamicRestMapper reloads and misses(because the CRD is not yet created), and we get an error from client.Get()
, then we can just rely on backoff of the controller's workqueue right?
https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/internal/controller/controller.go#L210-L215
If this call is not in the reconcile loop, then I imagine most likely the operator exits and restarts in the absence of a retry.
66caccc
to
2e8ce2d
Compare
/retest |
We probably want to update the changelog with this change as well |
2e8ce2d
to
9d5c44c
Compare
This addresses a controller-runtime bug which can affect operators that create CRD's and then CR's that refer to them, as the default mapper never "sees" the new CRD's. Fixes operator-framework#1328 (originally from @danwinship)
9d5c44c
to
2a5335a
Compare
changelog updated. i think i got the rebase right. lemme know if you need anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR didn't fix my problem in #1330, which I was thinking it should have fixed it: Make sure I'm running 0.8.0:
But I still see the error:
|
This addresses a controller-runtime bug which can affect operators
that create CRD's and then CR's that refer to them, as the default
mapper never "sees" the new CRD's.
Fixes #1328 (originally from @danwinship)