diff --git a/src/agent.py b/src/agent.py index 7bb8e959..29c8e9e3 100644 --- a/src/agent.py +++ b/src/agent.py @@ -62,6 +62,8 @@ def _on_deprecated_agent_relation_joined(self, event: ops.RelationJoinedEvent) - """ container = self.charm.unit.get_container(JENKINS_SERVICE_NAME) if not container.can_connect() or not self.state.is_storage_ready: + logger.warning("Service not yet ready. Deferring.") + event.defer() return # The relation is joined, it cannot be None, hence the type casting. deprecated_agent_relation_meta = typing.cast( @@ -101,6 +103,8 @@ def _on_agent_relation_joined(self, event: ops.RelationJoinedEvent) -> None: """ container = self.charm.unit.get_container(JENKINS_SERVICE_NAME) if not container.can_connect() or not self.state.is_storage_ready: + logger.warning("Service not yet ready. Deferring.") + event.defer() return # The relation is joined, it cannot be None, hence the type casting. agent_relation_meta = typing.cast( @@ -144,6 +148,7 @@ def _on_deprecated_agent_relation_departed(self, event: ops.RelationDepartedEven # the event unit cannot be None. container = self.charm.unit.get_container(JENKINS_SERVICE_NAME) if not container.can_connect() or not self.state.is_storage_ready: + logger.warning("Relation departed before service ready.") return # The relation data is removed before this particular hook runs, making the name set by the @@ -171,6 +176,7 @@ def _on_agent_relation_departed(self, event: ops.RelationDepartedEvent) -> None: # the event unit cannot be None. container = self.charm.unit.get_container(JENKINS_SERVICE_NAME) if not container.can_connect() or not self.state.is_storage_ready: + logger.warning("Relation departed before service ready.") return # The relation data is removed before this particular hook runs, making the name set by the