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

fix(Harness): remove special-casing for get_relation in leader-elected #1156

Merged

Conversation

tonyandrewmeyer
Copy link
Contributor

@tonyandrewmeyer tonyandrewmeyer commented Mar 21, 2024

In Juju, using get_relation() in a leader-elected event will return None if the relation does not yet exist. This makes Harness consistent with that behaviour.

This does remove a safety-check for badly written tests - where you mean for the relation to exist but forget to do an add_relation() call first in the test. However, we don't have any sort of check like this for any other events, or any other types of relations, and it should be obvious when the test fails that it's failing to find an expected relation, and the solution is to set that relation up. I don't think it's worth having a warning for this specific case (we don't warn in other similar situations).

This also means we can remove a check in model.py that's a no-op in production and does work in Harness, which is a bad smell, in my opinion.

Done:

Fixes #1153

@tonyandrewmeyer
Copy link
Contributor Author

The answer is that this is current behaviour, not guaranteed behaviour. So it's extra bad for ops (Harness) to behave like it's guaranteed.

@tonyandrewmeyer tonyandrewmeyer marked this pull request as ready for review March 21, 2024 23:50
@benhoyt benhoyt merged commit 9ebc3f9 into canonical:main Mar 22, 2024
28 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the leader-elected-get-relation-1153 branch March 26, 2024 03:46
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.

Harness and Juju behave differently when using model.get_relation in leader-elected
2 participants