-
Notifications
You must be signed in to change notification settings - Fork 33
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
base reconciler reconciles status #752
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #752 +/- ##
==========================================
+ Coverage 80.20% 82.86% +2.66%
==========================================
Files 64 77 +13
Lines 4492 6001 +1509
==========================================
+ Hits 3603 4973 +1370
- Misses 600 677 +77
- Partials 289 351 +62
Flags with carried forward coverage won't be shown. Click here to find out more.
|
api/v1beta2/ratelimitpolicy_types.go
Outdated
switch status := statusObject.(type) { | ||
case *RateLimitPolicyStatus: | ||
r.Status = *status |
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 not sure about this silently failing if the wrong kind of StatusObject
is passed in, it seems wrong. At the same time I don't think just logging an error message is enough.
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.
Maybe we could return error
if as a default
case (nothing matched) and we set the status to nil
? we could bubble up that error and decide given the setter expectations what to do
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.
before considering returning an error
, any suggestion?
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.
My mind is starting to go to extremes and I really don't know how well it suits. I am thinking that raising a panic might be the correct approach. If we return an error the reconcile ends up doing possibly twos things. One logs the error message, and two, reschedule the reconcile to try again. But if the wrong type is being past in, it was most likely an error caused by a developer in the code base where no matter how many times it is reschedule, reconcile, it will never pass.
I know causing the panic is extreme and not really done in operators, but I don't see how it would ever natural recover.
I do wonder what this would look like if the function is made more generalized and taken off the struct its self. But possible would have other issue, along with some of the same issue that I can currently visualize in my head.
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.
thanks for the ideas... let me think and try something else. I reckon the type assertion is a bad smell.
0524541
to
0b1f8cd
Compare
I have tried a different approach. Iteration number 2. I do not like the This is not entirely clean approach either and there is still a chance to mistakenly mix types by the developer, so the status updater tries again and again returning error. But it is also true that it is the same mutator approach as the controllers use to reconcile resource specs (not status). It is being used by all the controllers and never hit any issue like that. So I think it should be good enough. You might be interested in looking at the envoygateway controller implementation of the generic status updater: https://github.com/envoyproxy/gateway/blob/main/internal/provider/kubernetes/status_updater.go#L72-L121 |
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.
There was the one documentation issue, but other than that every thing is working as I expected. This newer method seems far nicer than before.
Co-authored-by: Jim Fitzpatrick <[email protected]>
9140ecf
to
f694367
Compare
good catch. Addressed |
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.
Looks good to me
What
Common status reconciler. The signature
Then, it can be used as follows:
And the mutator looks like
Work being done as part of #530
This is part of a series of PR's that will end with a new controller that will only reconcile limitador limits configuration.