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

ops.ErrorStatus is read-only and cannot be set #159

Closed
tonyandrewmeyer opened this issue Feb 9, 2024 · 2 comments · Fixed by #157 or #198
Closed

ops.ErrorStatus is read-only and cannot be set #159

tonyandrewmeyer opened this issue Feb 9, 2024 · 2 comments · Fixed by #157 or #198
Labels
enhancement New feature or request

Comments

@tonyandrewmeyer
Copy link

The restart_exporter() method will return ops.ErrorStatus("...") in some situations, and this is used to set the unit status.

However, this doesn't work - Juju will return a ERROR invalid status "error", expected one of [maintenance blocked waiting active] error, which ops will turn into a ModelError. The charm does end up in an error state, but because setting the status crashed, not because you've explicitly set the error state.

This is caught by the existing unit tests if you run with ops >= 2.10 (because Harness now models the Juju behaviour).

@Pjack Pjack added the bug Something isn't working label Feb 19, 2024
@Pjack Pjack modified the milestones: 23.10.5, 23.10.4 Feb 19, 2024
@Pjack Pjack linked a pull request Feb 19, 2024 that will close this issue
@Pjack Pjack closed this as completed Feb 19, 2024
@tonyandrewmeyer
Copy link
Author

@Pjack #157 works around this issue, but it doesn't actually fix it (and it stops you from getting any further improvements in ops until this is properly fixed). If you want the Charm to die with an error state, then there are cleaner ways of doing that. I think you probably want some other status though - most likely BlockedStatus - unless you are looking for specific error behaviour (like Juju retrying).

@Pjack
Copy link

Pjack commented Mar 4, 2024

Thanks for the remind~ I decide to reopen it and find time to figure out how to enhance it.

@Pjack Pjack reopened this Mar 4, 2024
@Pjack Pjack removed this from the 23.10.4 milestone Mar 4, 2024
@Pjack Pjack added enhancement New feature or request and removed bug Something isn't working labels Mar 4, 2024
@Pjack Pjack linked a pull request Mar 28, 2024 that will close this issue
@Pjack Pjack closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants