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

Defer database event when username is None #1005

Merged
merged 5 commits into from
Jul 28, 2023

Conversation

babakks
Copy link
Member

@babakks babakks commented Jul 19, 2023

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

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

@@ -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:
Copy link
Contributor

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:

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@@ -161,6 +161,11 @@ def _on_database_event(self, event: DatabaseRequiresEvent):
event.defer()
return

if event.username is None:
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@ale8k ale8k left a 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
Copy link
Contributor

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

Copy link
Contributor

@kian99 kian99 left a 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

@babakks babakks merged commit b0bf509 into canonical:main Jul 28, 2023
7 checks passed
@babakks babakks deleted the fix-none-username branch July 28, 2023 12:54
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.

4 participants