From 08fd035bbd22b7ba82038282e67ff99688ca1d9c Mon Sep 17 00:00:00 2001 From: Judit Novak Date: Thu, 20 Jul 2023 15:08:18 +0200 Subject: [PATCH] Eventually consistent -- sleep after write --- src/charm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/charm.py b/src/charm.py index aebb7ea..5f88fb8 100755 --- a/src/charm.py +++ b/src/charm.py @@ -13,6 +13,7 @@ """ import logging +import time import ops from ops import ActiveStatus, SecretNotFoundError @@ -105,11 +106,13 @@ def set_secret(self, key: str, value: str) -> None: content.update({key: value}) logger.info(f"Setting secret {secret.id} to {content}") secret.set_content(content) + time.sleep(10) else: content = { key: value, } secret = self.app.add_secret(content) + time.sleep(10) self.app_peer_data["secret-id"] = secret.id logger.info(f"Added secret {secret.id} to {content}") @@ -130,6 +133,7 @@ def delete_secret(self, key: str) -> None: logger.info(f"Remaining content is {list(content.keys())}") if content: secret.set_content(content) + time.sleep(10) else: secret.remove_all_revisions() del self.app_peer_data["secret-id"]