Skip to content

Commit

Permalink
move workload allowed to start check
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed Oct 22, 2024
1 parent 328f126 commit 816cbf6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/abstract_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ def reconcile(self, event=None) -> None: # noqa: C901
exposed_read_only_endpoint=self._exposed_read_only_endpoint,
shell=workload_.shell,
)
# todo: consider moving `self.refresh.workload_allowed_to_start` inside `workload._reconcile()`
if workload_.container_ready and self.refresh.workload_allowed_to_start:
if workload_.container_ready:
workload_.reconcile(
event=event,
tls=self._tls_certificate_saved,
unit_name=self.unit.name,
workload_allowed_to_start=self.refresh.workload_allowed_to_start,
exporter_config=self._cos_exporter_config(event),
key=self._tls_key,
certificate=self._tls_certificate,
Expand All @@ -297,7 +297,11 @@ def reconcile(self, event=None) -> None: # noqa: C901
self.refresh.next_unit_allowed_to_refresh = True
# TODO add comment about unit started for scale up case since start event will fire after relation created
# TODO add checks to reconcile debug log
elif workload_.status == ops.WaitingStatus() and self._unit_started.exists():
elif (
self.refresh.workload_allowed_to_start
and workload_.status == ops.WaitingStatus()
and self._unit_started.exists()
):
if self._database_requires.does_relation_exist(event):
# Waiting for relation-changed event before starting workload
pass
Expand Down
15 changes: 15 additions & 0 deletions src/workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def reconcile(
event,
tls: bool,
unit_name: str,
workload_allowed_to_start: bool,
exporter_config: "relations.cos.ExporterConfig",
key: str = None,
certificate: str = None,
Expand Down Expand Up @@ -362,12 +363,26 @@ def reconcile(
event,
tls: bool,
unit_name: str,
workload_allowed_to_start: bool,
exporter_config: "relations.cos.ExporterConfig",
key: str = None,
certificate: str = None,
certificate_authority: str = None,
) -> None:
"""Reconcile all workloads (router, exporter, tls)."""
if not workload_allowed_to_start:
super().reconcile(
event=event,
tls=tls,
unit_name=unit_name,
workload_allowed_to_start=workload_allowed_to_start,
exporter_config=exporter_config,
key=key,
certificate=certificate,
certificate_authority=certificate_authority,
)
return

if tls and not (key and certificate and certificate_authority):
raise ValueError(
"`key`, `certificate`, and `certificate_authority` arguments required when tls=True"
Expand Down

0 comments on commit 816cbf6

Please sign in to comment.