-
Notifications
You must be signed in to change notification settings - Fork 5
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
Defer database event when username
is None
#1005
Conversation
Signed-off-by: Babak K. Shandiz <[email protected]>
charms/jimm-k8s/src/charm.py
Outdated
@@ -316,6 +316,11 @@ def _on_dashboard_relation_joined(self, event: RelationJoinedEvent): | |||
def _on_database_event(self, event: DatabaseEvent) -> None: | |||
"""Database event handler.""" | |||
|
|||
if event.username is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly if not event.username or not event.password:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
charms/jimm/src/charm.py
Outdated
@@ -161,6 +161,11 @@ def _on_database_event(self, event: DatabaseRequiresEvent): | |||
event.defer() | |||
return | |||
|
|||
if event.username is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here.. but these are really just nitpicks.. feel free to ignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]>
Signed-off-by: Babak K. Shandiz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm honestly
@@ -1,6 +1,6 @@ | |||
markupsafe>=2.0.1 | |||
Jinja2 >= 2.11.3 | |||
ops >= 1.4.0 | |||
ops >= 2.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's interesting that this used to work. I wonder if pip or some other tool recently updated and changed its behavior
Description
Sometimes data platform libs provide the database event handler with
username=None
. This PR fixes the issue by deferring the event.Engineering checklist
Check only items that apply