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

Report WaitingStatus for relations that have not requested user & database #48

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/relations/database_provides.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def delete_all_databags(self) -> None:
def get_status(self, event) -> typing.Optional[ops.StatusBase]:
"""Report non-active status."""
requested_users = []
exception_reporting_priority = (
_UnsupportedExtraUserRole,
remote_databag.IncompleteDatabag,
)
# TODO python3.10 min version: Use `list` instead of `typing.List`
exceptions: typing.List[status_exception.StatusException] = []
for relation in self._interface.relations:
Expand All @@ -247,16 +251,11 @@ def get_status(self, event) -> typing.Optional[ops.StatusBase]:
)
except _RelationBreaking:
pass
except (remote_databag.IncompleteDatabag, _UnsupportedExtraUserRole) as exception:
except exception_reporting_priority as exception:
exceptions.append(exception)
# Always report unsupported extra user role
for exception in exceptions:
if isinstance(exception, _UnsupportedExtraUserRole):
return exception.status
if requested_users:
# At least one relation is active—do not report about inactive relations
return
for exception in exceptions:
if isinstance(exception, remote_databag.IncompleteDatabag):
return exception.status
return ops.BlockedStatus(f"Missing relation: {self._NAME}")
for exception_type in exception_reporting_priority:
for exception in exceptions:
if isinstance(exception, exception_type):
return exception.status
if not requested_users:
return ops.BlockedStatus(f"Missing relation: {self._NAME}")
Loading