Skip to content

Commit

Permalink
Reset flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Feb 7, 2024
1 parent 66698e3 commit 6427c8f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def __init__(self, *args):
self,
relation_name=PEER_RELATION_NAME,
additional_secret_fields=[
AUTH_FILE_DATABAG_KEY,
MONITORING_PASSWORD_KEY,
self._translate_field_to_secret_key(AUTH_FILE_DATABAG_KEY),
self._translate_field_to_secret_key(MONITORING_PASSWORD_KEY),
],
secret_field_name=SECRET_INTERNAL_LABEL,
deleted_label=SECRET_DELETED_LABEL,
Expand Down Expand Up @@ -250,16 +250,8 @@ def _on_pgbouncer_pebble_ready(self, event: PebbleReadyEvent) -> None:
if auth_file := self.get_secret(APP_SCOPE, AUTH_FILE_DATABAG_KEY):
self.render_auth_file(auth_file)

tls_enabled = all(self.tls.get_tls_files())
if self.model.relations.get("certificates", []) and not tls_enabled:
logger.debug(
"pgbouncer_pebble_ready: Deferring as certificates files are not yet populated for existing certificates relation"
)
self.unit.status = WaitingStatus("Waiting for certificates")
event.defer()
return
# in case of pod restart
elif tls_enabled:
if all(self.tls.get_tls_files()):
self.push_tls_files_to_workload(False)

pebble_layer = self._pgbouncer_layer()
Expand All @@ -270,6 +262,8 @@ def _on_pgbouncer_pebble_ready(self, event: PebbleReadyEvent) -> None:

self.unit.set_workload_version(self.version)

self.peers.unit_databag["container_initialised"] = "True"

if JujuVersion.from_environ().supports_open_port_on_k8s:
self.unit.open_port("tcp", self.config["listen_port"])
else:
Expand All @@ -278,7 +272,10 @@ def _on_pgbouncer_pebble_ready(self, event: PebbleReadyEvent) -> None:
@property
def is_container_ready(self) -> bool:
"""Check if we can connect to the container and it was already initialised."""
return self.unit.get_container(PGB).can_connect()
return (
self.unit.get_container(PGB).can_connect()
and "container_initialised" in self.peers.unit_databag
)

def _on_config_changed(self, event: ConfigChangedEvent) -> None:
"""Handle changes in configuration.
Expand Down

0 comments on commit 6427c8f

Please sign in to comment.