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

Cleanup router metadata #224

Merged
merged 21 commits into from
May 18, 2023
Merged

Cleanup router metadata #224

merged 21 commits into from
May 18, 2023

Conversation

carlcsaposs-canonical
Copy link
Contributor

Depends on #220 (change base branch after #220 is merged)

Issue

Router metadata not removed when router leaves relation

Solution

Remove metadata when router leaves relation

Base automatically changed from delete-router-users to main May 11, 2023 12:36
@carlcsaposs-canonical
Copy link
Contributor Author

Depends on #226

@carlcsaposs-canonical carlcsaposs-canonical marked this pull request as ready for review May 12, 2023 18:14
src/relations/mysql_provider.py Show resolved Hide resolved
self.charm._mysql.delete_user(user.username)
logger.info(f"Deleted router user {user.username}")
except MySQLDeleteUserError:
logger.error(f"Failed to delete user {user.username}")
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should defer/retry if the deletion fails.
up to @paulomach

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd agree - if there's a error dropping a user it maybe the case to retry - I've also commented on the lib method to make it harder to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can this be a separate PR?

we're not doing this for other user deletion (e.g. deleting users for relation)

self.charm._mysql.delete_users_for_relation(relation_id)

I'd prefer to not block canonical/mysql-router-k8s-operator#51

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #228

src/relations/mysql_provider.py Outdated Show resolved Hide resolved
if len(users) > 1:
logger.error(
f"More than one router user for departing unit {event.departing_unit.name}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

isnt it possible to have more than 1 user returned (if there are multiple applications related to the mysqlrouter application)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lib/charms/mysql/v0/mysql.py Outdated Show resolved Hide resolved
lib/charms/mysql/v0/mysql.py Outdated Show resolved Hide resolved
self.charm._mysql.delete_user(user.username)
logger.info(f"Deleted router user {user.username}")
except MySQLDeleteUserError:
logger.error(f"Failed to delete user {user.username}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd agree - if there's a error dropping a user it maybe the case to retry - I've also commented on the lib method to make it harder to fail.

Copy link
Contributor

@paulomach paulomach left a comment

Choose a reason for hiding this comment

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

lgtm

@carlcsaposs-canonical carlcsaposs-canonical merged commit c2e396f into main May 18, 2023
@carlcsaposs-canonical carlcsaposs-canonical deleted the cleanup-router-metadata branch May 18, 2023 11:16
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