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
1=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
2--- lib/ubuntu_repository_cache/metadata_sync.py 2022-07-22 06:33:43 +0000
3+++ lib/ubuntu_repository_cache/metadata_sync.py 2022-07-28 00:39:07 +0000
4@@ -8,6 +8,7 @@
5 import pwd
6 import shutil
7 import socket
8+import subprocess
9 import time
10 import traceback
11
12@@ -15,8 +16,6 @@
13 from datetime import datetime
14 from itertools import cycle
15
16-from subprocess import CalledProcessError, check_call, check_output, DEVNULL, STDOUT
17-
18 from .util import (
19 FileSemaphore,
20 REPO_SYNC_CRON_LOG,
21@@ -70,7 +69,7 @@
22 # around subprocess - ~tribaal
23
24
25-def rsync(from_path, to_path, options, log, flags="-r", check_output=check_output, user=None, timeout=None):
26+def rsync(from_path, to_path, options, log, flags="-r", check_output=subprocess.check_output, user=None, timeout=None):
27 """
28 A wrapper around subprocess to execute an rsync between a source and a
29 destination.
30@@ -93,10 +92,10 @@
31 cmd.append(to_path)
32 log(" ".join(cmd))
33
34- return check_output(cmd, stderr=STDOUT).decode('UTF-8').strip()
35-
36-
37-def symlink(source, destination, log=None, check_call=check_call):
38+ return check_output(cmd, stderr=subprocess.STDOUT).decode('UTF-8').strip()
39+
40+
41+def symlink(source, destination, log=None, check_call=subprocess.check_call):
42 """
43 A wrapper around subprocess to create a symlink between the source and the
44 destination name.
45@@ -258,7 +257,7 @@
46 return os.path.basename(dest)
47
48
49-def main(environment, log, mirror_archive=mirror_archive, check_call=check_call):
50+def main(environment, log, mirror_archive=mirror_archive, check_call=subprocess.check_call):
51 """The main function for this script.
52
53 This is called at the very bottom of this file should the file be executed
54@@ -293,7 +292,12 @@
55
56 log("Executing hook: {}".format(cmd))
57
58- check_call(cmd, stdout=DEVNULL)
59+ try:
60+ check_call(cmd, stdout=subprocess.DEVNULL)
61+ except subprocess.CalledProcessError:
62+ metric_name = 'ubuntu_repository_cache_metadata_sync_failures'
63+ send_to_influx(render_influx(metric_name, '', 1))
64+ raise
65
66 return meta_ver
67
68@@ -377,7 +381,9 @@
69 log("Keeping {}".format(entry))
70
71
72-@backoff.on_exception(backoff.expo, CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup)
73+@backoff.on_exception(
74+ backoff.expo, subprocess.CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup
75+)
76 def _mirror_metadata(archive_ip, dest, link_dest, log, mirror_series, rsync_module='ubuntu'):
77 '''Mirror metadata from the archive.'''
78
79@@ -415,7 +421,9 @@
80 rsync(rsync_source, dest, rsync_options, log, user='www-sync', timeout=4800)
81
82
83-@backoff.on_exception(backoff.expo, CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup)
84+@backoff.on_exception(
85+ backoff.expo, subprocess.CalledProcessError, max_tries=RSYNC_MAX_RETRIES, giveup=rsync_should_giveup
86+)
87 @backoff.on_exception(backoff.expo, UpstreamMirrorSyncError, max_tries=UPSTREAM_SYNC_MAX_RETRIES, factor=60)
88 def _mirror_base(apache_root, archive_ip, dest, log=None, rsync_module='ubuntu'):
89 """Mirror just the root of the archive.
90
91=== modified file 'wheelhouse.txt'
92--- wheelhouse.txt 2022-07-25 00:15:09 +0000
93+++ wheelhouse.txt 2022-07-28 00:39:07 +0000
94@@ -1,4 +1,5 @@
95 # Include python requirements here
96-backoff<=1.7.0
97+# Drop to 1.6.0 which dramatically reduces build time (while still supporting Xenial)
98+backoff==1.6.0
99 # Xenial & py35 support - https://github.com/juju-solutions/layer-basic/pull/197
100 MarkupSafe<2.0.0

Subscribers

People subscribed via source and target branches