Merge ~vultaire/charm-nagios:skip-dedupe-prefix-for-same-model into charm-nagios:master

Proposed by Paul Goins
Status: Merged
Approved by: Garrett Neugent
Approved revision: bfe338c0d3570047847d00ef66ed8b2660ad1c7f
Merged at revision: 1425e19f775dfcdad94518e79848f5fa88d29e37
Proposed branch: ~vultaire/charm-nagios:skip-dedupe-prefix-for-same-model
Merge into: charm-nagios:master
Prerequisite: ~vultaire/charm-nagios:remove-legacy-deduping
Diff against target: 22 lines (+8/-1)
1 file modified
hooks/monitors_relation_changed.py (+8/-1)
Reviewer Review Type Date Requested Status
Garrett Neugent (community) Approve
Xav Paice (community) Approve
🤖 prod-jenkaas-bootstack continuous-integration Approve
BootStack Reviewers Pending
Review via email: mp+407757@code.launchpad.net

Commit message

Fixed deduping to skip the prefix if not needed

Deduplication is only performed if there are 2 or more related units
with the same target hostname from different models. If there are
"duplicates" but they are from the same model (e.g. multiple nrpe units
associated with different principal apps on the same host), it is
probably preferable to have those "coalesce" into a single host, rather
than having distinct records with redundant checks.

To post a comment you must log in.
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Paul Goins (vultaire) wrote :

Results of testing on serverstack, adding a second nrpe app to the same principal host app:

* Without the changes, I end up with no duplicate hosts, but I end up with the prefix.
* With the changes, the prefix disappears as well.
* The prefix does still show up if I have a duplicate on a different model, i.e. the intended case for adding the prefix still works.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Xav Paice (xavpaice) wrote :

LGTM

review: Approve
Revision history for this message
Garrett Neugent (thogarre) wrote :

nice! LGTM as well.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 1425e19f775dfcdad94518e79848f5fa88d29e37

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/monitors_relation_changed.py b/hooks/monitors_relation_changed.py
2index 2a201c6..4c86a63 100755
3--- a/hooks/monitors_relation_changed.py
4+++ b/hooks/monitors_relation_changed.py
5@@ -160,9 +160,16 @@ def main(argv, full_rewrite=False): # noqa: C901
6 duplicate_hostnames = set()
7 all_hosts = {}
8 for target_id, relation_settings_list in hosts_to_settings.items():
9+ related_model_ids = set(
10+ [
11+ relation_settings.get(MODEL_ID_KEY)
12+ for relation_settings in relation_settings_list
13+ ]
14+ )
15+ deduping_required = len(related_model_ids) > 1
16 for relation_settings in relation_settings_list:
17 model_id = relation_settings.get(MODEL_ID_KEY)
18- if model_id and len(relation_settings_list) > 1:
19+ if model_id and deduping_required:
20 duplicate_hostnames.add(target_id)
21 unique_prefix = host_prefixes[model_id]
22 relation_settings[TARGET_ID_KEY] = "{}_{}".format(

Subscribers

People subscribed via source and target branches

to all changes: