Skip to content
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

Timing issue at start with AbstractEventSource #417

Closed
shawkins opened this issue May 4, 2021 · 14 comments
Closed

Timing issue at start with AbstractEventSource #417

shawkins opened this issue May 4, 2021 · 14 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@shawkins
Copy link
Collaborator

shawkins commented May 4, 2021

This is a minor issue. Event sources can start receiving events before the controller init is called. This requires a null check of the eventHandler or you'll get npe exceptions for a while. Perhaps AbstractEventSource could implement EventHandler and take care of the relevant null checks.

Related to this should the AbstractEventSource.eventHandler field be volatile?

@metacosm
Copy link
Collaborator

metacosm commented May 5, 2021

Is this still going on in the latest version?

@shawkins
Copy link
Collaborator Author

shawkins commented May 5, 2021

I haven't checked. The event source is an application scoped bean. Events can start flowing as a side effect of a quarkus onStart hook. Should the operator init be guaranteed to happen before that? And/or do you want this as a quarkus specific issue?

@lburgazzoli
Copy link
Collaborator

lburgazzoli commented May 7, 2021

I think now you should override EventSource.start and EventSource.close for a proper lifecycle, so i.e. watching for events starts only after that the event handler has been set.

@metacosm
Copy link
Collaborator

metacosm commented May 7, 2021

Can we close this issue?

@shawkins
Copy link
Collaborator Author

shawkins commented May 7, 2021

Can we close this issue?

Yes. Based upon our current code, we'll just stick with a null check. We don't want to process any events until all of the informers have started/synced.

@metacosm
Copy link
Collaborator

metacosm commented May 8, 2021

I'll add a null check to AbstractEventSource regardless. Thank you!

@shawkins
Copy link
Collaborator Author

shawkins commented May 8, 2021

I'll add a null check to AbstractEventSource regardless. Thank you!

Do you mean have AbstractEventSource implement EventHandler and handle the null check in AbstractEventSource.handleEvent?

@metacosm
Copy link
Collaborator

That was the plan but maybe it might cause more trouble than worth? Another idea was to potentially buffer the events that are received while the event handler isn't set so that they can be replayed when it is, but I'm not sure that makes sense…

@shawkins
Copy link
Collaborator Author

Our scenario is that we want all of the informers to have synced before any of the events (primary custom resource or the operands are processed) so that we can use the associated Store/Cache and it will be relatively up-to-date. This wasn't straight-forward with the default implementation of informers in the fabric8 client, so we are temporarily using our own while the upstream is refined. So in our case individual starts aren't really meaningful.

Another idea was to potentially buffer the events that are received while the event handler isn't set so that they can be replayed when it is, but I'm not sure that makes sense…

That is not needed in our case - as long as the primary custom resource events get processed after the initial sync, we can simply ignore any of the other events until then.

@shawkins
Copy link
Collaborator Author

Thanks, once our upgrade to quarkus 1.13.1 / operator sdk 1.8.2 moves forward I'll make use of that.

@shawkins
Copy link
Collaborator Author

@metacosm I'm trying this out now with 1.8.2 and it doesn't appear to work. DelayRegistrationUntil has a source retention policy. At least when I try to debug what is happening, I see that when OperatorSDKProcessor.createControllerConfiguration is looking for the annotation it can't find it.

@jmrodri
Copy link
Member

jmrodri commented Sep 2, 2021

/assign @jmrodri

@jmrodri jmrodri added the kind/bug Categorizes issue or PR as related to a bug. label Sep 2, 2021
@csviri
Copy link
Collaborator

csviri commented Oct 29, 2021

Will close this, since we implemented the start/stop (close) methods meanwhile.

@csviri csviri closed this as completed Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

5 participants