From a405fd96b6ad6c4a88aa7b4cb3e6d1515b2a2435 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 29 Jul 2024 11:39:04 +0300 Subject: [PATCH] address comments #2 --- src/charm.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/charm.py b/src/charm.py index 2227962..ff1e7c1 100755 --- a/src/charm.py +++ b/src/charm.py @@ -84,11 +84,7 @@ def __init__(self, *args): self.framework.observe(self.on.collect_unit_status, self._on_collect_unit_status) # refuse to handle any other event as we can't possibly know what to do. - if ( - not self.coordinator.cluster.has_workers - or not self.coordinator.is_coherent - or not self.coordinator.s3_ready - ): + if not self.coordinator.can_handle_events: # logging will be handled by `self.coordinator` for each of the above circumstances. return @@ -144,11 +140,23 @@ def _external_url(self) -> str: def _internal_url(self) -> str: """Returns workload's FQDN.""" scheme = "http" - if hasattr(self, "coordinator") and self.coordinator.nginx.are_certificates_on_disk: + if self.are_certificates_on_disk: scheme = "https" return f"{scheme}://{self.hostname}" + @property + def are_certificates_on_disk(self) -> bool: + """Return True if the certificates files are on disk.""" + nginx_container = self.unit.get_container("nginx") + + return ( + nginx_container.can_connect() + and nginx_container.exists(CERT_PATH) + and nginx_container.exists(KEY_PATH) + and nginx_container.exists(CA_CERT_PATH) + ) + @property def enabled_receivers(self) -> Set[str]: """Extra receivers enabled through config"""