Merge lp:~hloeung/ubuntu-repository-cache/metadata-sync-to-peers-less-juju-3 into lp:ubuntu-repository-cache

Proposed by Haw Loeung
Status: Superseded
Proposed branch: lp:~hloeung/ubuntu-repository-cache/metadata-sync-to-peers-less-juju-3
Merge into: lp:ubuntu-repository-cache
Prerequisite: lp:~hloeung/ubuntu-repository-cache/metadata-sync-to-peers-less-juju-2
Diff against target: 172 lines (+21/-38)
3 files modified
lib/ubuntu_repository_cache/metadata_cleanup.py (+4/-9)
lib/ubuntu_repository_cache/metadata_peers_sync.py (+4/-11)
lib/ubuntu_repository_cache/metadata_sync.py (+13/-18)
To merge this branch: bzr merge lp:~hloeung/ubuntu-repository-cache/metadata-sync-to-peers-less-juju-3
Reviewer Review Type Date Requested Status
Canonical IS Reviewers Pending
Ubuntu Repository Cache Charmers, Canonical Pending
Review via email: mp+429032@code.launchpad.net

This proposal has been superseded by a proposal from 2022-08-29.

Commit message

Fix to ensure consistent importing of util per previous review

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
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Unable to determine commit message from repository - please click "Set commit message" and enter the commit message manually.

399. By Haw Loeung

black formatting fixes

Unmerged revisions

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_cleanup.py'
2--- lib/ubuntu_repository_cache/metadata_cleanup.py 2022-08-24 00:08:03 +0000
3+++ lib/ubuntu_repository_cache/metadata_cleanup.py 2022-08-29 00:31:23 +0000
4@@ -6,12 +6,7 @@
5 from .metadata_sync import (
6 clean_metadata_dir,
7 )
8-from .util import (
9- FileSemaphore,
10- SemaphoreExistsError,
11- render_influx,
12- send_to_influx,
13-)
14+from . import util
15
16
17 # Log file and directory for the repository sync cron job
18@@ -48,13 +43,13 @@
19
20 start_time = time.time()
21 try:
22- with FileSemaphore(SEMAPHORE_FILE):
23+ with util.FileSemaphore(SEMAPHORE_FILE):
24 cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__")
25 main(environment, cache_logger.info)
26 cache_logger.info("Metadata cleanup from __main__ ended.")
27
28 duration = time.time() - start_time
29 metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration'
30- send_to_influx(render_influx(metric_name, '', duration))
31- except SemaphoreExistsError:
32+ util.send_to_influx(util.render_influx(metric_name, '', duration))
33+ except util.SemaphoreExistsError:
34 cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
35
36=== modified file 'lib/ubuntu_repository_cache/metadata_peers_sync.py'
37--- lib/ubuntu_repository_cache/metadata_peers_sync.py 2022-08-29 00:31:23 +0000
38+++ lib/ubuntu_repository_cache/metadata_peers_sync.py 2022-08-29 00:31:23 +0000
39@@ -8,13 +8,6 @@
40 from . import mirror
41 from . import service
42 from . import util
43-from .util import (
44- REPO_SYNC_LOG,
45- FileSemaphore,
46- SemaphoreExistsError,
47- render_influx,
48- send_to_influx,
49-)
50
51
52 SEMAPHORE_FILE = '/tmp/metadata-peers-sync-running'
53@@ -98,7 +91,7 @@
54 # move to leverage the logging infrastructure better. ~tribaal
55 import logging
56
57- file_handler = logging.FileHandler(REPO_SYNC_LOG)
58+ file_handler = logging.FileHandler(util.REPO_SYNC_LOG)
59 file_handler.setLevel(logging.INFO)
60
61 basic_formatter = logging.Formatter('%(asctime)s - %(message)s')
62@@ -112,13 +105,13 @@
63
64 start_time = time.time()
65 try:
66- with FileSemaphore(SEMAPHORE_FILE):
67+ with util.FileSemaphore(SEMAPHORE_FILE):
68 cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__")
69 ubuntu_repository_cache_sync(environment, cache_logger.info)
70 cache_logger.info("Metadata peers sync from __main__ ended.")
71
72 duration = time.time() - start_time
73 metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration'
74- send_to_influx(render_influx(metric_name, '', duration))
75- except SemaphoreExistsError:
76+ util.send_to_influx(util.render_influx(metric_name, '', duration))
77+ except util.SemaphoreExistsError:
78 cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
79
80=== modified file 'lib/ubuntu_repository_cache/metadata_sync.py'
81--- lib/ubuntu_repository_cache/metadata_sync.py 2022-08-29 00:31:23 +0000
82+++ lib/ubuntu_repository_cache/metadata_sync.py 2022-08-29 00:31:23 +0000
83@@ -18,14 +18,7 @@
84 from collections import OrderedDict
85 from itertools import cycle
86
87-from .util import (
88- FileSemaphore,
89- REPO_SYNC_LOG,
90- SemaphoreExistsError,
91- SEMAPHORE_FILE,
92- render_influx,
93- send_to_influx,
94-)
95+from . import util
96
97 import backoff
98
99@@ -201,7 +194,7 @@
100 log('Sync from {} completed.'.format(archive_ip))
101 duration = time.time() - upstream_sync_start_time
102 metric_name = 'ubuntu_repository_cache_metadata_sync_upstream_duration'
103- send_to_influx(render_influx(metric_name, 'upstream_host={}'.format(archive_ip), duration))
104+ util.send_to_influx(util.render_influx(metric_name, 'upstream_host={}'.format(archive_ip), duration))
105
106 log('Starting repository mirror verification.')
107 verification_start_time = time.time()
108@@ -216,7 +209,7 @@
109 log('Successful repository mirror verification.')
110 duration = time.time() - verification_start_time
111 metric_name = 'ubuntu_repository_cache_metadata_sync_verification_duration'
112- send_to_influx(render_influx(metric_name, '', duration))
113+ util.send_to_influx(util.render_influx(metric_name, '', duration))
114 content_mirrored = True
115
116 if not content_mirrored:
117@@ -317,7 +310,7 @@
118 msg = "{}".format(output)
119 log(msg)
120 except subprocess.CalledProcessError as e:
121- send_to_influx(render_influx(metric_name, label, attempt))
122+ util.send_to_influx(util.render_influx(metric_name, label, attempt))
123 failures = attempt
124 # Save the exact exception and reuse when we need to
125 # reraise it after exhausting all available attempts.
126@@ -333,7 +326,7 @@
127 else:
128 break
129 else:
130- send_to_influx(render_influx(metric_name, label, max_retries))
131+ util.send_to_influx(util.render_influx(metric_name, label, max_retries))
132 print('\n'.join(errmsgs))
133 # Exhausted all available attempts, let's re-raise the
134 # exception.
135@@ -343,7 +336,7 @@
136 sys.stdout.flush()
137 raise exp
138
139- send_to_influx(render_influx(metric_name, label, failures))
140+ util.send_to_influx(util.render_influx(metric_name, label, failures))
141 return meta_ver
142
143
144@@ -610,7 +603,7 @@
145 # move to leverage the logging infrastructure better. ~tribaal
146 import logging
147
148- file_handler = logging.FileHandler(REPO_SYNC_LOG)
149+ file_handler = logging.FileHandler(util.REPO_SYNC_LOG)
150 file_handler.setLevel(logging.INFO)
151
152 basic_formatter = logging.Formatter('%(asctime)s - %(message)s')
153@@ -628,13 +621,15 @@
154
155 start_time = time.time()
156 try:
157- with FileSemaphore(SEMAPHORE_FILE):
158+ with util.FileSemaphore(util.SEMAPHORE_FILE):
159 cache_logger.info("Metadata sync started from metadata_sync.py:__main__")
160 main(environment, cache_logger.info)
161 cache_logger.info("Metadata sync from __main__ ended.")
162
163 duration = time.time() - start_time
164 metric_name = 'ubuntu_repository_cache_metadata_sync_duration'
165- send_to_influx(render_influx(metric_name, 'upstream_host={}'.format(environment["SYNC_HOST"]), duration))
166- except SemaphoreExistsError:
167- cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
168+ util.send_to_influx(
169+ util.render_influx(metric_name, 'upstream_host={}'.format(environment["SYNC_HOST"]), duration)
170+ )
171+ except util.SemaphoreExistsError:
172+ cache_logger.info("Can't acquire semaphore: {} already exists.".format(util.SEMAPHORE_FILE))

Subscribers

People subscribed via source and target branches