Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use as_dict() because label_matcher_dict excludes unit #67

Merged
merged 7 commits into from
Mar 8, 2024

Conversation

Abuelodelanada
Copy link
Contributor

@Abuelodelanada Abuelodelanada commented Mar 6, 2024

Issue

This PR fixes #61

Solution

We stop using label_matcher_dict because removes unit.

@@ -700,10 +700,17 @@ class COSAgentRequirer(Object):
 
                 # Apply labels to the scrape jobs
                 for static_config in job.get("static_configs", []):
+                    topo_as_dict = topology.as_dict(excluded_keys=["charm_name"])
                     static_config["labels"] = {
                         # Be sure to keep labels from static_config
                         **static_config.get("labels", {}),
-                        **topology.as_dict(excluded_keys=["charm_name"]),
+                        # TODO: We should add a new method in juju_topology.py
+                        # that like `as_dict` method, returns the keys with juju_ prefix
+                        **{
+                            "juju_{}".format(key): value
+                            for key, value in topo_as_dict.items()
+                            if value
+                        },

TODO:

Add itest mimicking this deployment

Testing Instructions

@Abuelodelanada Abuelodelanada marked this pull request as ready for review March 7, 2024 17:32
@Abuelodelanada Abuelodelanada merged commit 31d1295 into main Mar 8, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect labels after relating to grafana-agent rev 38
3 participants