Merge lp:~hloeung/ubuntu-repository-cache/metrics-include-leader-unit into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Rejected
Rejected by: Haw Loeung
Proposed branch: lp:~hloeung/ubuntu-repository-cache/metrics-include-leader-unit
Merge into: lp:ubuntu-repository-cache
Diff against target: 104 lines (+16/-5)
5 files modified
lib/ubuntu_repository_cache/metadata_sync.py (+7/-4)
lib/ubuntu_repository_cache/mirror.py (+1/-1)
lib/ubuntu_repository_cache/service.py (+1/-0)
lib/ubuntu_repository_cache/tests/test_metadata_sync.py (+2/-0)
templates/cron/ubuntu-repository-cache-config (+5/-0)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/metrics-include-leader-unit
Reviewer Review Type Date Requested Status
Haw Loeung Disapprove
Canonical IS Reviewers Pending
Review via email: mp+428679@code.launchpad.net

Commit message

Include leader unit, or which unit we're syncing from, in metrics; Fix naming of peer sync failures metric so it's consistent

To post a comment you must log in.
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
Haw Loeung (hloeung) wrote :

Metrics only come from the leader unit, so this is not needed.

review: Disapprove

Unmerged revisions

381. By Haw Loeung

Fix naming of metric so it's consistent

380. By Haw Loeung

Include leader unit, or which unit we're syncing from, in metrics

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
2--- lib/ubuntu_repository_cache/metadata_sync.py 2022-08-22 00:32:23 +0000
3+++ lib/ubuntu_repository_cache/metadata_sync.py 2022-08-22 03:43:52 +0000
4@@ -142,7 +142,7 @@
5 # END OF VENDORING OF CHARMHELPERS FUNCTIONS.
6
7
8-def mirror_archive(hostname, apache_root, local_unit, log, mirror_series, rsync_module='ubuntu'): # NOQA: C901
9+def mirror_archive(hostname, apache_root, leader_unit, local_unit, log, mirror_series, rsync_module='ubuntu'): # NOQA: C901, E501
10 """Sync Ubuntu repository metadata to the mirror.
11
12 Metadata synchronization is performed and then the metadata is
13@@ -201,7 +201,8 @@
14 log('Sync from {} completed.'.format(archive_ip))
15 duration = time.time() - upstream_sync_start_time
16 metric_name = 'ubuntu_repository_cache_metadata_sync_upstream_duration'
17- send_to_influx(render_influx(metric_name, 'upstream_host={}'.format(archive_ip), duration))
18+ labels = 'upstream_host={},leader_unit={}'.format(archive_ip, leader_unit)
19+ send_to_influx(render_influx(metric_name, labels, duration))
20
21 log('Starting repository mirror verification.')
22 verification_start_time = time.time()
23@@ -272,11 +273,12 @@
24 except KeyError:
25 rsync_module = 'ubuntu'
26 apache_root = environment["APACHE_ROOT"]
27+ leader_unit = environment["LEADER_UNIT"]
28 local_unit = environment["LOCAL_UNIT"]
29 unit_path = environment["UNIT_PATH"]
30 mirror_series = environment["MIRROR_SERIES"]
31
32- meta_ver = mirror_archive(sync_host, apache_root, local_unit, log, mirror_series, rsync_module=rsync_module)
33+ meta_ver = mirror_archive(sync_host, apache_root, leader_unit, local_unit, log, mirror_series, rsync_module=rsync_module) # NOQA: E501
34 if meta_ver is None:
35 # If we failed to download and/or validate a new version of the
36 # archives, don't propagate the information to other units.
37@@ -622,6 +624,7 @@
38
39 duration = time.time() - start_time
40 metric_name = 'ubuntu_repository_cache_metadata_sync_total_duration'
41- send_to_influx(render_influx(metric_name, 'upstream_host={}'.format(environment["SYNC_HOST"]), duration))
42+ labels = 'upstream_host={},leader_unit={}'.format(environment["SYNC_HOST"], environment["LEADER_UNIT"])
43+ send_to_influx(render_influx(metric_name, labels, duration))
44 except SemaphoreExistsError:
45 cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
46
47=== modified file 'lib/ubuntu_repository_cache/mirror.py'
48--- lib/ubuntu_repository_cache/mirror.py 2022-08-22 00:32:23 +0000
49+++ lib/ubuntu_repository_cache/mirror.py 2022-08-22 03:43:52 +0000
50@@ -92,7 +92,7 @@
51 rsync_dest = '{}@{}:{}'.format(user, peer, dest_dir)
52 LOG('Syncing {} to {}.'.format(source_dir, rsync_dest))
53
54- metric_name = 'ubuntu_repository_cache_metadata_sync_to_peers_failures'
55+ metric_name = 'ubuntu_repository_cache_metadata_sync_peers_failures'
56 label = 'peer={}'.format(peer)
57 failures = 0
58
59
60=== modified file 'lib/ubuntu_repository_cache/service.py'
61--- lib/ubuntu_repository_cache/service.py 2022-07-27 23:26:52 +0000
62+++ lib/ubuntu_repository_cache/service.py 2022-08-22 03:43:52 +0000
63@@ -286,6 +286,7 @@
64 # Add Juju model name and AZ so it's easier to work out which region sent out cron emails.
65 cron_context['JujuModelName'] = os.environ.get('JUJU_MODEL_NAME')
66 cron_context['JujuAvailabilityZone'] = os.environ.get('JUJU_AVAILABILITY_ZONE')
67+ cron_context['LeaderUnit'] = config['leader_unit']
68 templating.render('cron/ubuntu-repository-cache_rsync.cron', cron_filename, cron_context)
69 templating.render('cron/ubuntu-repository-cache-config', urc_config_path, cron_context)
70 else:
71
72=== modified file 'lib/ubuntu_repository_cache/tests/test_metadata_sync.py'
73--- lib/ubuntu_repository_cache/tests/test_metadata_sync.py 2022-08-09 08:39:55 +0000
74+++ lib/ubuntu_repository_cache/tests/test_metadata_sync.py 2022-08-22 03:43:52 +0000
75@@ -151,6 +151,7 @@
76 "SYNC_HOST": "foo.com",
77 "MIRROR_SERIES": "xenial",
78 "APACHE_ROOT": "/var/www/",
79+ "LEADER_UNIT": "unit/0",
80 "LOCAL_UNIT": "unit/0",
81 "UNIT_PATH": "something",
82 }
83@@ -166,6 +167,7 @@
84 "SYNC_HOST": "foo.com",
85 "MIRROR_SERIES": "xenial",
86 "APACHE_ROOT": "/var/www/",
87+ "LEADER_UNIT": "unit/0",
88 "LOCAL_UNIT": "unit/0",
89 "UNIT_PATH": "something",
90 }
91
92=== modified file 'templates/cron/ubuntu-repository-cache-config'
93--- templates/cron/ubuntu-repository-cache-config 2019-09-09 05:35:39 +0000
94+++ templates/cron/ubuntu-repository-cache-config 2022-08-22 03:43:52 +0000
95@@ -1,4 +1,9 @@
96 export APACHE_ROOT={{ ApacheRoot }}
97+export JUJU_MODEL_NAME={{ JujuModelName }}
98+{%- if JujuAvailabilityZone %}
99+export JUJU_AVAILABILITY_ZONE={{ JujuAvailabilityZone }}
100+{%- endif %}
101+export LEADER_UNIT={{ LeaderUnit }}
102 export LOCAL_UNIT={{ UnitId }}
103 export MIRROR_SERIES="{{ MirrorSeries }}"
104 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Subscribers

People subscribed via source and target branches