Skip to content

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

Merged
merged 10 commits into from
Sep 30, 2022

Conversation

metacosm
Copy link
Collaborator

@metacosm metacosm commented Sep 21, 2022

Requires fabric8io/kubernetes-client#4412

  • chore: update to SNAPSHOT version of fabric8 client
  • feat: enable configuring a handler to listen to informers stopping

@metacosm metacosm self-assigned this Sep 21, 2022
@metacosm metacosm requested a review from csviri September 21, 2022 16:22
Copy link
Collaborator

@csviri csviri left a 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)

@metacosm
Copy link
Collaborator Author

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.

@csviri
Copy link
Collaborator

csviri commented Sep 23, 2022

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,

@csviri
Copy link
Collaborator

csviri commented Sep 23, 2022

cc @andreaTP
could you review this pls, should be support your use case.

Copy link
Collaborator

@andreaTP andreaTP left a 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) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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…

Copy link
Collaborator

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 .

Copy link
Collaborator Author

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.

Copy link
Contributor

@vmuzikar vmuzikar left a 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!

Copy link
Collaborator

@csviri csviri left a 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 {
Copy link
Collaborator

@csviri csviri Sep 30, 2022

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 ?

Copy link
Collaborator Author

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.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

50.7% 50.7% Coverage
0.0% 0.0% Duplication

@metacosm metacosm merged commit 9bb3f07 into v3 Sep 30, 2022
@metacosm metacosm deleted the informer-exception-handler branch September 30, 2022 14:15
metacosm added a commit to quarkiverse/quarkus-operator-sdk that referenced this pull request Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Operator should trigger the error state of the CR when deserialization fails
4 participants