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
diff --git a/lib/ubuntu_repository_cache/metadata_cleanup.py b/lib/ubuntu_repository_cache/metadata_cleanup.py
index ad0bb2e..6d74cf5 100644
--- a/lib/ubuntu_repository_cache/metadata_cleanup.py
+++ b/lib/ubuntu_repository_cache/metadata_cleanup.py
@@ -14,9 +14,6 @@ REPO_SYNC_DIR = '/var/log/ubuntu-repository-cache'
14REPO_SYNC_LOG = os.path.join(REPO_SYNC_DIR, 'metadata-cleanup.log')14REPO_SYNC_LOG = os.path.join(REPO_SYNC_DIR, 'metadata-cleanup.log')
1515
1616
17SEMAPHORE_FILE = '/tmp/metadata-cleanup-running'
18
19
20def main(environment, log):17def main(environment, log):
21 apache_root = environment['APACHE_ROOT']18 apache_root = environment['APACHE_ROOT']
22 clean_metadata_dir(apache_root, log)19 clean_metadata_dir(apache_root, log)
@@ -42,14 +39,10 @@ if __name__ == "__main__":
42 environment = os.environ39 environment = os.environ
4340
44 start_time = time.time()41 start_time = time.time()
45 try:42 cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__")
46 with util.FileSemaphore(SEMAPHORE_FILE):43 main(environment, cache_logger.info)
47 cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__")44 cache_logger.info("Metadata cleanup from __main__ ended.")
48 main(environment, cache_logger.info)45
49 cache_logger.info("Metadata cleanup from __main__ ended.")46 duration = time.time() - start_time
5047 metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration'
51 duration = time.time() - start_time48 util.send_to_influx(util.render_influx(metric_name, '', duration))
52 metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration'
53 util.send_to_influx(util.render_influx(metric_name, '', duration))
54 except util.SemaphoreExistsError:
55 cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))
diff --git a/lib/ubuntu_repository_cache/metadata_peers_sync.py b/lib/ubuntu_repository_cache/metadata_peers_sync.py
index 9c8a0b4..5be276f 100644
--- a/lib/ubuntu_repository_cache/metadata_peers_sync.py
+++ b/lib/ubuntu_repository_cache/metadata_peers_sync.py
@@ -10,9 +10,6 @@ from . import service
10from . import util10from . import util
1111
1212
13SEMAPHORE_FILE = '/tmp/metadata-peers-sync-running'
14
15
16def parse_config(conf=service.CONFIG_PATH):13def parse_config(conf=service.CONFIG_PATH):
17 keys = {}14 keys = {}
18 cmd = ['bash', '-c', "trap 'env -0' exit; source {} > /dev/null 2>&1".format(conf)]15 cmd = ['bash', '-c', "trap 'env -0' exit; source {} > /dev/null 2>&1".format(conf)]
@@ -104,14 +101,10 @@ if __name__ == "__main__":
104 environment = os.environ101 environment = os.environ
105102
106 start_time = time.time()103 start_time = time.time()
107 try:104 cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__")
108 with util.FileSemaphore(SEMAPHORE_FILE):105 ubuntu_repository_cache_sync(environment, cache_logger.info)
109 cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__")106 cache_logger.info("Metadata peers sync from __main__ ended.")
110 ubuntu_repository_cache_sync(environment, cache_logger.info)107
111 cache_logger.info("Metadata peers sync from __main__ ended.")108 duration = time.time() - start_time
112109 metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration'
113 duration = time.time() - start_time110 util.send_to_influx(util.render_influx(metric_name, '', duration))
114 metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration'
115 util.send_to_influx(util.render_influx(metric_name, '', duration))
116 except util.SemaphoreExistsError:
117 cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE))

Subscribers

People subscribed via source and target branches