-
Notifications
You must be signed in to change notification settings - Fork 220
feat: enable configuring a handler to listen to informers stopping #1493
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
Conversation
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,
would it be possible to add an integration test? (not sure how though)
I'm not sure either apart from what we already test in this PR. Note also that the informer part is already tested in the fabric8 client, we just need to test our integration, which I believe we do somewhat in this PR. |
Yep, no doubt this is good enough. Just meatn in a way if that would be easy to do, would not harm, |
cc @andreaTP |
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.
Great work! Thanks a lot!
One little comment and a question.
How do we inject this from a Reconciler
?
Would it be possible to use it in one of the examples?
ConfigurationServiceProvider.instance().getInformerStoppedHandler() | ||
.ifPresent(ish -> { | ||
final var stopped = informer.stopped(); | ||
if (stopped != null) { |
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.
in which condition stopped
is going to be null
?
With the current implementation in the client
it doesn't seem to be possible.
I would leave this check out to fail early if this erroneous situation appears.
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.
Good point. This happens during tests, though, where it would require quite a bit of setup just to mock the future…
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 would rather prefer more setup in the tests as opposed to the risk of this to happen and be swallowed in a real operator.
The risk here is to end up with a non-working callback without noticing.
If you are really, really against doing it, I should, at least, ask for a loud warning when this situation occurs .
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.
It's now explicit so there's no way to silently fail anymore.
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 played around with it with Keycloak Operator and can confirm it works well for our use-case. Thanks!
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.
just one tiny naming issue
|
||
import io.fabric8.kubernetes.client.informers.SharedIndexInformer; | ||
|
||
public interface InformerStoppedHandler { |
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.
Would rather rename it to InformerStopHandler
?
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 think the current name is better because it reflects the fact that the handler is called after the informer is stopped.
Kudos, SonarCloud Quality Gate passed! |
Requires fabric8io/kubernetes-client#4412