Changing the order of the dictionaries to unpack makes sure that pre-exising labels have priority over the automatically-generated topology.
Testing Instructions
Modify a charm (e.g., blackbox) to specify a custom juju_application label; then relate it to two Prometheus instances (one without the fix, the other with the fix) and check the difference in the targets section.
Before:
After:
There is a unit test that explicitly checks that we do overwrite the topology labels (and it's aptly called test_consumer_overwrites_juju_topology_labels, in the file tests/unit/test_endpoint_consumer.py). I'm removing that test, since it doesn't really make sense with this PR :)
I would like another pair of eyes to confirm this PR is something we want to do!
Issue
Closes #571.
Solution
Changing the order of the dictionaries to unpack makes sure that pre-exising labels have priority over the automatically-generated topology.
Testing Instructions
Modify a charm (e.g., blackbox) to specify a custom
juju_application
label; then relate it to two Prometheus instances (one without the fix, the other with the fix) and check the difference in the targets section.Before:![Screenshot_20240424_100749](https://github.com/canonical/prometheus-k8s-operator/assets/36242061/a9cad247-f96f-4ebc-939e-923af651a5c1)
After:![Screenshot_20240424_100923](https://github.com/canonical/prometheus-k8s-operator/assets/36242061/38721d59-4cb9-4414-861b-5ac92fe79e01)
There is a unit test that explicitly checks that we do overwrite the topology labels (and it's aptly called
test_consumer_overwrites_juju_topology_labels
, in the filetests/unit/test_endpoint_consumer.py
). I'm removing that test, since it doesn't really make sense with this PR :)I would like another pair of eyes to confirm this PR is something we want to do!