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 logic in _on_config_changed event #285

Conversation

zxhdaze
Copy link
Contributor

@zxhdaze zxhdaze commented Aug 5, 2024

Fixes: #284, #215

Issue #284 arises because there's no return statement following the defer() in the _on_config_changed event. When hardware-observer is deployed without a resource, the _on_config_changed event triggers, but no exporter gets installed. In the absence of a return statement, the function continues execution and may attempt to restart an exporter that hasn't been installed, which lead to a crash.

For the second fix mentioned in #215, the configuration is not rendered if the cos-agent relation is not provided. Considering this is a life cycle issue, I suggest we do not change it here and leave it to be modified in the next life cycle change.

@zxhdaze zxhdaze marked this pull request as ready for review August 5, 2024 20:25
@zxhdaze zxhdaze requested a review from a team as a code owner August 5, 2024 20:25
Copy link
Contributor

@jneo8 jneo8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Life cycle issue to discuss

src/charm.py Show resolved Hide resolved
tests/unit/test_charm.py Outdated Show resolved Hide resolved
tests/unit/test_charm.py Outdated Show resolved Hide resolved
gabrielcocenza
gabrielcocenza previously approved these changes Aug 7, 2024
Copy link
Member

@gabrielcocenza gabrielcocenza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just details to make the PR with less changes

tests/unit/test_charm.py Show resolved Hide resolved
tests/unit/test_charm.py Show resolved Hide resolved
src/charm.py Show resolved Hide resolved
@zxhdaze zxhdaze merged commit cd1055d into canonical:main Aug 8, 2024
4 checks passed
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.

hardware-exporter service wasn't installed when cos_agent relation is provided
6 participants