File tree Expand file tree Collapse file tree 4 files changed +70
-1
lines changed Expand file tree Collapse file tree 4 files changed +70
-1
lines changed Original file line number Diff line number Diff line change @@ -459,6 +459,10 @@ def _reconcile_mysqld_exporter(
459
459
self , event : RelationCreatedEvent | RelationBrokenEvent
460
460
) -> None :
461
461
"""Handle a COS relation created or broken event."""
462
+ if not self ._is_peer_data_set :
463
+ logger .debug ("Unit not yet ready to reconcile mysqld exporter. Waiting..." )
464
+ return
465
+
462
466
container = self .unit .get_container (CONTAINER_NAME )
463
467
if not container .can_connect ():
464
468
# reconciliation is done on pebble ready
Original file line number Diff line number Diff line change
1
+ bundle: kubernetes
2
+ name: testing
3
+ applications:
4
+ mysql-k8s:
5
+ charm: {{ mysql_charm_path }}
6
+ trust: true
7
+ scale: 1
8
+ constraints: mem=2G
9
+ resources:
10
+ mysql-image: {{ mysql_image_source }}
11
+ grafana-agent-k8s:
12
+ charm: grafana-agent-k8s
13
+ channel: latest/stable
14
+ scale: 1
15
+ relations:
16
+ - [mysql-k8s:metrics-endpoint, grafana-agent-k8s:metrics-endpoint]
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # Copyright 2024 Canonical Ltd.
3
+ # See LICENSE file for licensing details.
4
+
5
+ import logging
6
+ import pathlib
7
+ import tempfile
8
+
9
+ import jinja2
10
+ import pytest
11
+ import yaml
12
+ from pytest_operator .plugin import OpsTest
13
+
14
+ logger = logging .getLogger (__name__ )
15
+
16
+ METADATA = yaml .safe_load (pathlib .Path ("./metadata.yaml" ).read_text ())
17
+ IMAGE_SOURCE = METADATA ["resources" ]["mysql-image" ]["upstream-source" ]
18
+ TIMEOUT = 10 * 60
19
+
20
+
21
+ @pytest .mark .group (1 )
22
+ @pytest .mark .abort_on_fail
23
+ async def test_deploy_bundle_with_cos_integrations (ops_test : OpsTest ) -> None :
24
+ """Test COS integrations formed before mysql is allocated and deployed."""
25
+ logger .info ("Building the mysql-k8s charm" )
26
+ charm_path = await ops_test .build_charm ("." )
27
+
28
+ bundle_template = jinja2 .Template (
29
+ pathlib .Path (
30
+ "./tests/integration/bundle_templates/grafana_agent_integration.j2"
31
+ ).read_text ()
32
+ )
33
+ rendered_bundle = bundle_template .render (
34
+ mysql_charm_path = str (charm_path ), mysql_image_source = IMAGE_SOURCE
35
+ )
36
+
37
+ with tempfile .NamedTemporaryFile (mode = "w+" , suffix = ".yaml" ) as rendered_bundle_file :
38
+ rendered_bundle_file .write (rendered_bundle )
39
+ rendered_bundle_file .flush ()
40
+
41
+ logger .info ("Deploying grafana_agent_integration bundle" )
42
+ await ops_test .model .deploy (f"local:{ rendered_bundle_file .name } " , trust = True )
43
+
44
+ logger .info ("Waiting until mysql-k8s becomes active" )
45
+ await ops_test .model .wait_for_idle (
46
+ apps = ["mysql-k8s" ],
47
+ status = "active" ,
48
+ raise_on_blocked = True ,
49
+ timeout = TIMEOUT ,
50
+ )
You can’t perform that action at this time.
0 commit comments