diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a9a7f7cb..2708da12 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,6 +9,9 @@ jobs: unit-tests: name: Unit Tests uses: canonical/operator-workflows/.github/workflows/test.yaml@main + permissions: + contents: read + pull-requests: write secrets: inherit with: self-hosted-runner: false @@ -18,6 +21,9 @@ jobs: uses: canonical/operator-workflows/.github/workflows/integration_test.yaml@main secrets: inherit + permissions: + contents: read + packages: write with: channel: 1.33-strict/stable charmcraft-channel: latest/edge diff --git a/connectors/abuseipdb_ipblacklist/lib/charms/opencti/v0/opencti_connector.py b/connectors/abuseipdb_ipblacklist/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/abuseipdb_ipblacklist/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/abuseipdb_ipblacklist/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/alienvault/lib/charms/opencti/v0/opencti_connector.py b/connectors/alienvault/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/alienvault/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/alienvault/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/cisa_kev/lib/charms/opencti/v0/opencti_connector.py b/connectors/cisa_kev/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/cisa_kev/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/cisa_kev/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/crowdstrike/lib/charms/opencti/v0/opencti_connector.py b/connectors/crowdstrike/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/crowdstrike/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/crowdstrike/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/cyber_campaign/lib/charms/opencti/v0/opencti_connector.py b/connectors/cyber_campaign/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/cyber_campaign/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/cyber_campaign/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/export_file_csv/lib/charms/opencti/v0/opencti_connector.py b/connectors/export_file_csv/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/export_file_csv/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/export_file_csv/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/export_file_stix/lib/charms/opencti/v0/opencti_connector.py b/connectors/export_file_stix/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/export_file_stix/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/export_file_stix/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/export_file_txt/lib/charms/opencti/v0/opencti_connector.py b/connectors/export_file_txt/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/export_file_txt/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/export_file_txt/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/import_document/lib/charms/opencti/v0/opencti_connector.py b/connectors/import_document/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/import_document/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/import_document/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/import_file_stix/lib/charms/opencti/v0/opencti_connector.py b/connectors/import_file_stix/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/import_file_stix/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/import_file_stix/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/ipinfo/lib/charms/opencti/v0/opencti_connector.py b/connectors/ipinfo/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/ipinfo/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/ipinfo/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/malwarebazaar/lib/charms/opencti/v0/opencti_connector.py b/connectors/malwarebazaar/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/malwarebazaar/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/malwarebazaar/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/misp_feed/lib/charms/opencti/v0/opencti_connector.py b/connectors/misp_feed/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/misp_feed/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/misp_feed/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/mitre/lib/charms/opencti/v0/opencti_connector.py b/connectors/mitre/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/mitre/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/mitre/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/nti/lib/charms/opencti/v0/opencti_connector.py b/connectors/nti/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/nti/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/nti/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/sekoia/lib/charms/opencti/v0/opencti_connector.py b/connectors/sekoia/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/sekoia/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/sekoia/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/urlhaus/lib/charms/opencti/v0/opencti_connector.py b/connectors/urlhaus/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/urlhaus/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/urlhaus/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/urlscan/lib/charms/opencti/v0/opencti_connector.py b/connectors/urlscan/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/urlscan/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/urlscan/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/urlscan_enrichment/lib/charms/opencti/v0/opencti_connector.py b/connectors/urlscan_enrichment/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/urlscan_enrichment/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/urlscan_enrichment/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/virustotal_livehunt/lib/charms/opencti/v0/opencti_connector.py b/connectors/virustotal_livehunt/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/virustotal_livehunt/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/virustotal_livehunt/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/connectors/vxvault/lib/charms/opencti/v0/opencti_connector.py b/connectors/vxvault/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/connectors/vxvault/lib/charms/opencti/v0/opencti_connector.py +++ b/connectors/vxvault/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector") diff --git a/lib/charms/opencti/v0/opencti_connector.py b/lib/charms/opencti/v0/opencti_connector.py index fa26bd57..ca4a467f 100644 --- a/lib/charms/opencti/v0/opencti_connector.py +++ b/lib/charms/opencti/v0/opencti_connector.py @@ -228,23 +228,26 @@ def _reconcile_connector(self) -> None: container = self.unit.get_container(self.meta.name) if not container.can_connect(): raise NotReady("waiting for container ready") - container.add_layer( - "connector", - layer=ops.pebble.LayerDict( - summary=self.meta.name, - description=self.meta.name, - services={ - "connector": { - "startup": "enabled", - "on-failure": "restart", - "override": "replace", - "command": "bash /entrypoint.sh", - "environment": self._gen_env(), + try: + container.add_layer( + "connector", + layer=ops.pebble.LayerDict( + summary=self.meta.name, + description=self.meta.name, + services={ + "connector": { + "startup": "enabled", + "on-failure": "restart", + "override": "replace", + "command": "bash /entrypoint.sh", + "environment": self._gen_env(), + }, }, - }, - ), - combine=True, - ) + ), + combine=True, + ) + except TimeoutError as exc: + raise Blocked("Timeout while adding pebble layer, will retry.") from exc try: container.replan() container.start("connector")