diff --git a/lib/charms/mongodb/v1/mongodb_provider.py b/lib/charms/mongodb/v1/mongodb_provider.py index 99cde1585..467fafebd 100644 --- a/lib/charms/mongodb/v1/mongodb_provider.py +++ b/lib/charms/mongodb/v1/mongodb_provider.py @@ -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