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

Clean-up relation_changed.emit() calls #265

Closed
phvalguima opened this issue Apr 26, 2024 · 2 comments · Fixed by #266
Closed

Clean-up relation_changed.emit() calls #265

phvalguima opened this issue Apr 26, 2024 · 2 comments · Fixed by #266
Labels
bug Something isn't working

Comments

@phvalguima
Copy link
Contributor

I noticed that we are generating an disproportionate amount of opensearch_peers_relation_changed events that are getting constantly deferred. That increases significantly the startup time.

One example:

2024-04-26 14:16:51 DEBUG unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: Re-emitting deferred event <ConfigChangedEvent via OpenSearchOperatorCharm/on/config_changed[36]>.
2024-04-26 14:16:52 WARNING unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: 'app' expected but not received.
2024-04-26 14:16:52 WARNING unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: 'app_name' expected in snapshot but not found.
2024-04-26 14:16:52 DEBUG unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: Emitting custom event <RelationChangedEvent via OpenSearchOperatorCharm/on/opensearch_peers_relation_changed[47]>.
2024-04-26 14:16:52 ERROR unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: [Errno 111] Connection refused
2024-04-26 14:16:52 ERROR unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: [Errno 111] Connection refused
2024-04-26 14:16:52 ERROR unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: [Errno 111] Connection refused
2024-04-26 14:16:53 DEBUG unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: Deferring <RelationChangedEvent via OpenSearchOperatorCharm/on/opensearch_peers_relation_changed[47]>.
2024-04-26 14:16:53 ERROR unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: [Errno 111] Connection refused
2024-04-26 14:16:53 WARNING unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: Plugin management: cluster not ready yet at config changed
2024-04-26 14:16:53 DEBUG unit.opensearch/2.juju-log server.go:325 opensearch-peers:1: Deferring <ConfigChangedEvent via OpenSearchOperatorCharm/on/config_changed[36]>.

We can see that RelationChangedEvent via OpenSearchOperatorCharm/on/opensearch_peers_relation_changed gets constantly created and deferred in the process.

My recommendation is to replace any known relation_* emits for actual calls to their handler functions.

@phvalguima phvalguima added the bug Something isn't working label Apr 26, 2024
Copy link
Contributor

@phvalguima
Copy link
Contributor Author

Opened an issue to request these events to be converted to singletons canonical/operator#1205

phvalguima added a commit that referenced this issue May 1, 2024
We should replace calls to `relation_{joined,changed}.emit()` by their
end-method's handler. Otherwise we will face situations like #265, where
a deferred event constantly gets called up, generates new events which
also get deferred and end in a snow ball of deferrals.

Closes #265

---------

Co-authored-by: Mehdi Bendriss <bendrissmehdi@gmail.com>
Co-authored-by: Carl Csaposs <carl.csaposs@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant