Skip to content

Commit 025afd6

Browse files
authored
fix: DPE-7497 ensure early logging_provider relation wont break init (#616)
* avoid race on early relation to logging provider * limit test to amd64 * passwordless ssh on runner * libpatch bump * revert lib changes as its not needed
1 parent 3491c74 commit 025afd6

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

src/charm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def unit_initialized(self, raise_exceptions: bool = False) -> bool:
325325
"""
326326
container = self.unit.get_container(CONTAINER_NAME)
327327
if container.can_connect():
328-
return super().unit_initialized()
328+
return super().unit_initialized(raise_exceptions)
329329
else:
330330
return False
331331

src/log_rotation_setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ def _update_logs_rotation(self, _):
9292
self.charm.unit_peer_data[_LOGS_SYNCED] = "true"
9393
self.setup()
9494

95-
def _cos_relation_created(self, _):
95+
def _cos_relation_created(self, event):
9696
"""Handle relation created."""
9797
container = self.charm.unit.get_container(CONTAINER_NAME)
9898
if not container.can_connect():
9999
return
100+
101+
if not self.charm.app_peer_data.get("cluster-name"):
102+
event.defer()
103+
logger.info("Cluster name not set, deferring log rotation setup")
104+
return
105+
100106
logger.info("Reconfigure log rotation on cos relation created")
101107
self.setup()
102108

tests/integration/bundle_templates/grafana_agent_integration.j2

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ applications:
1313
channel: 1/stable
1414
scale: 1
1515
relations:
16-
- [mysql-k8s:metrics-endpoint, grafana-agent-k8s:metrics-endpoint]
16+
- - grafana-agent-k8s:logging-provider
17+
- mysql-k8s:logging
18+
- - grafana-agent-k8s:metrics-endpoint
19+
- mysql-k8s:metrics-endpoint

tests/integration/test_cos_integration_bundle.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
import yaml
1212
from pytest_operator.plugin import OpsTest
1313

14+
from . import markers
15+
1416
logger = logging.getLogger(__name__)
1517

1618
METADATA = yaml.safe_load(pathlib.Path("./metadata.yaml").read_text())
1719
IMAGE_SOURCE = METADATA["resources"]["mysql-image"]["upstream-source"]
1820
TIMEOUT = 10 * 60
1921

2022

23+
# TODO: remove after https://github.com/canonical/grafana-agent-k8s-operator/issues/309 fixed
24+
@markers.amd64_only
2125
@pytest.mark.abort_on_fail
2226
async def test_deploy_bundle_with_cos_integrations(ops_test: OpsTest, charm) -> None:
2327
"""Test COS integrations formed before mysql is allocated and deployed."""

0 commit comments

Comments
 (0)