Skip to content

Commit

Permalink
update lib for removal
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaAltieri committed Oct 18, 2024
1 parent ec1ab03 commit a48f553
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/charms/mongodb/v1/mongodb_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,15 @@ def remove_all_relational_users(self):
self.database_provides.delete_relation_data(relation.id, fields=list(fields))

# unforatunately the above doesn't work to remove secrets, so we forcibly remove the rest
# manually remove the secret before clearing the databag
for unit in relation.units:
secret_id = json.loads(relation.data[unit]["data"])["secret-user"]
# secret id is the same on all units for `secret-user`
break

user_secrets = self.charm.model.get_secret(id=secret_id)
user_secrets.remove_all_revisions()
user_secrets.get_content(refresh=True)
relation.data[self.charm.app].clear()

@staticmethod
Expand Down

0 comments on commit a48f553

Please sign in to comment.