Merge ~hloeung/ubuntu-repository-cache:master into ubuntu-repository-cache:master

Proposed by Haw Loeung
Status: Merged
Approved by: Haw Loeung
Approved revision: 0ac066743bae6451da8cdbde9623f2179f730acb
Merged at revision: b411991e3fb4c9dbff9a2cb2ec075218f46d11af
Proposed branch: ~hloeung/ubuntu-repository-cache:master
Merge into: ubuntu-repository-cache:master
Diff against target: 72 lines (+14/-28)
2 files modified
lib/ubuntu_repository_cache/metadata_cleanup.py (+7/-14)
lib/ubuntu_repository_cache/metadata_peers_sync.py (+7/-14)
Reviewer Review Type Date Requested Status
Loïc Gomez +1 Approve
Canonical IS Reviewers Pending
Review via email: mp+430417@code.launchpad.net

Commit message

Remove the need for semaphore locking, these functions are wrapped and called via run-one

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
Loïc Gomez (kotodama) :
review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision b411991e3fb4c9dbff9a2cb2ec075218f46d11af

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/ubuntu_repository_cache/metadata_cleanup.py b/lib/ubuntu_repository_cache/metadata_cleanup.py
2index ad0bb2e..6d74cf5 100644
3--- a/lib/ubuntu_repository_cache/metadata_cleanup.py
4+++ b/lib/ubuntu_repository_cache/metadata_cleanup.py
5@@ -14,9 +14,6 @@ REPO_SYNC_DIR = '/var/log/ubuntu-repository-cache'
6 REPO_SYNC_LOG = os.path.join(REPO_SYNC_DIR, 'metadata-cleanup.log')
7
8
9-SEMAPHORE_FILE = '/tmp/metadata-cleanup-running'
10-
11-
12 def main(environment, log):
13 apache_root = environment['APACHE_ROOT']
14 clean_metadata_dir(apache_root, log)
15@@ -42,14 +39,10 @@ if __name__ == "__main__":
16 environment = os.environ
17
18 start_time = time.time()
19- try:
20- with util.FileSemaphore(SEMAPHORE_FILE):
21- cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__")
22- main(environment, cache_logger.info)
23- cache_logger.info("Metadata cleanup from __main__ ended.")
24-
25- duration = time.time() - start_time
26- metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration'
27- util.send_to_influx(util.render_influx(metric_name, '', duration))
28- except util.SemaphoreExistsError:
29- cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
30+ cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__")
31+ main(environment, cache_logger.info)
32+ cache_logger.info("Metadata cleanup from __main__ ended.")
33+
34+ duration = time.time() - start_time
35+ metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration'
36+ util.send_to_influx(util.render_influx(metric_name, '', duration))
37diff --git a/lib/ubuntu_repository_cache/metadata_peers_sync.py b/lib/ubuntu_repository_cache/metadata_peers_sync.py
38index 9c8a0b4..5be276f 100644
39--- a/lib/ubuntu_repository_cache/metadata_peers_sync.py
40+++ b/lib/ubuntu_repository_cache/metadata_peers_sync.py
41@@ -10,9 +10,6 @@ from . import service
42 from . import util
43
44
45-SEMAPHORE_FILE = '/tmp/metadata-peers-sync-running'
46-
47-
48 def parse_config(conf=service.CONFIG_PATH):
49 keys = {}
50 cmd = ['bash', '-c', "trap 'env -0' exit; source {} > /dev/null 2>&1".format(conf)]
51@@ -104,14 +101,10 @@ if __name__ == "__main__":
52 environment = os.environ
53
54 start_time = time.time()
55- try:
56- with util.FileSemaphore(SEMAPHORE_FILE):
57- cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__")
58- ubuntu_repository_cache_sync(environment, cache_logger.info)
59- cache_logger.info("Metadata peers sync from __main__ ended.")
60-
61- duration = time.time() - start_time
62- metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration'
63- util.send_to_influx(util.render_influx(metric_name, '', duration))
64- except util.SemaphoreExistsError:
65- cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
66+ cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__")
67+ ubuntu_repository_cache_sync(environment, cache_logger.info)
68+ cache_logger.info("Metadata peers sync from __main__ ended.")
69+
70+ duration = time.time() - start_time
71+ metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration'
72+ util.send_to_influx(util.render_influx(metric_name, '', duration))

Subscribers

People subscribed via source and target branches