Merge lp:~hloeung/ubuntu-repository-cache/juju-run-metrics into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 361
Merged at revision: 361
Proposed branch: lp:~hloeung/ubuntu-repository-cache/juju-run-metrics
Merge into: lp:ubuntu-repository-cache
Diff against target: 100 lines (+21/-12)
2 files modified
lib/ubuntu_repository_cache/metadata_sync.py (+19/-11)
wheelhouse.txt (+2/-1)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/juju-run-metrics
Reviewer Review Type Date Requested Status
James Simpson +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+427525@code.launchpad.net

Commit message

Add metric for juju-run failures

Description of the change

This is in preparation for updating the charm with retry logic.

First, we want metrics to see the frequency of failures and if it's just down to problematic regions.

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
James Simpson (jsimpso) wrote :

LGTM

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

Change successfully merged at revision 361

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
--- lib/ubuntu_repository_cache/metadata_sync.py 2022-07-22 06:33:43 +0000
+++ lib/ubuntu_repository_cache/metadata_sync.py 2022-07-28 00:39:07 +0000
@@ -8,6 +8,7 @@
8import pwd8import pwd
9import shutil9import shutil
10import socket10import socket
11import subprocess
11import time12import time
12import traceback13import traceback
1314
@@ -15,8 +16,6 @@
15from datetime import datetime16from datetime import datetime
16from itertools import cycle17from itertools import cycle
1718
18from subprocess import CalledProcessError, check_call, check_output, DEVNULL, STDOUT
19
20from .util import (19from .util import (
21 FileSemaphore,20 FileSemaphore,
22 REPO_SYNC_CRON_LOG,21 REPO_SYNC_CRON_LOG,
@@ -70,7 +69,7 @@
70# around subprocess - ~tribaal69# around subprocess - ~tribaal
7170
7271
73def rsync(from_path, to_path, options, log, flags="-r", check_output=check_output, user=None, timeout=None):72def rsync(from_path, to_path, options, log, flags="-r", check_output=subprocess.check_output, user=None, timeout=None):
74 """73 """
75 A wrapper around subprocess to execute an rsync between a source and a74 A wrapper around subprocess to execute an rsync between a source and a
76 destination.75 destination.
@@ -93,10 +92,10 @@
93 cmd.append(to_path)92 cmd.append(to_path)
94 log(" ".join(cmd))93 log(" ".join(cmd))
9594
96 return check_output(cmd, stderr=STDOUT).decode('UTF-8').strip()95 return check_output(cmd, stderr=subprocess.STDOUT).decode('UTF-8').strip()
9796
9897
99def symlink(source, destination, log=None, check_call=check_call):98def symlink(source, destination, log=None, check_call=subprocess.check_call):
100 """99 """
101 A wrapper around subprocess to create a symlink between the source and the100 A wrapper around subprocess to create a symlink between the source and the
102 destination name.101 destination name.
@@ -258,7 +257,7 @@
258 return os.path.basename(dest)257 return os.path.basename(dest)
259258
260259
261def main(environment, log, mirror_archive=mirror_archive, check_call=check_call):260def main(environment, log, mirror_archive=mirror_archive, check_call=subprocess.check_call):
262 """The main function for this script.261 """The main function for this script.
263262
264 This is called at the very bottom of this file should the file be executed263 This is called at the very bottom of this file should the file be executed
@@ -293,7 +292,12 @@
293292
294 log("Executing hook: {}".format(cmd))293 log("Executing hook: {}".format(cmd))
295294
296 check_call(cmd, stdout=DEVNULL)295 try:
296 check_call(cmd, stdout=subprocess.DEVNULL)
297 except subprocess.CalledProcessError:
298 metric_name = 'ubuntu_repository_cache_metadata_sync_failures'
299 send_to_influx(render_influx(metric_name, '', 1))
300 raise
297301
298 return meta_ver302 return meta_ver
299303
@@ -377,7 +381,9 @@
377 log("Keeping {}".format(entry))381 log("Keeping {}".format(entry))
378382
379383
380@backoff.on_exception(backoff.expo, CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup)384@backoff.on_exception(
385 backoff.expo, subprocess.CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup
386)
381def _mirror_metadata(archive_ip, dest, link_dest, log, mirror_series, rsync_module='ubuntu'):387def _mirror_metadata(archive_ip, dest, link_dest, log, mirror_series, rsync_module='ubuntu'):
382 '''Mirror metadata from the archive.'''388 '''Mirror metadata from the archive.'''
383389
@@ -415,7 +421,9 @@
415 rsync(rsync_source, dest, rsync_options, log, user='www-sync', timeout=4800)421 rsync(rsync_source, dest, rsync_options, log, user='www-sync', timeout=4800)
416422
417423
418@backoff.on_exception(backoff.expo, CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup)424@backoff.on_exception(
425 backoff.expo, subprocess.CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup
426)
419@backoff.on_exception(backoff.expo, UpstreamMirrorSyncError, max_tries=UPSTREAM_SYNC_MAX_RETRIES, factor=60)427@backoff.on_exception(backoff.expo, UpstreamMirrorSyncError, max_tries=UPSTREAM_SYNC_MAX_RETRIES, factor=60)
420def _mirror_base(apache_root, archive_ip, dest, log=None, rsync_module='ubuntu'):428def _mirror_base(apache_root, archive_ip, dest, log=None, rsync_module='ubuntu'):
421 """Mirror just the root of the archive.429 """Mirror just the root of the archive.
422430
=== modified file 'wheelhouse.txt'
--- wheelhouse.txt 2022-07-25 00:15:09 +0000
+++ wheelhouse.txt 2022-07-28 00:39:07 +0000
@@ -1,4 +1,5 @@
1# Include python requirements here1# Include python requirements here
2backoff<=1.7.02# Drop to 1.6.0 which dramatically reduces build time (while still supporting Xenial)
3backoff==1.6.0
3# Xenial & py35 support - https://github.com/juju-solutions/layer-basic/pull/1974# Xenial & py35 support - https://github.com/juju-solutions/layer-basic/pull/197
4MarkupSafe<2.0.05MarkupSafe<2.0.0

Subscribers

People subscribed via source and target branches