diff options
| author | Haw Loeung <[email protected]> | 2022-09-26 01:15:20 +0000 |
|---|---|---|
| committer | Canonical IS Mergebot <[email protected]> | 2022-09-26 01:15:20 +0000 |
| commit | b411991e3fb4c9dbff9a2cb2ec075218f46d11af (patch) | |
| tree | e864bdef25deb0576b090cfd84302cbf4bb3d595 | |
| parent | 0d12dfad3a627c78b4607ef14b294f4438cd7076 (diff) | |
| parent | 0ac066743bae6451da8cdbde9623f2179f730acb (diff) | |
Remove the need for semaphore locking, these functions are wrapped and called via run-onerev57
Reviewed-on: https://code.launchpad.net/~hloeung/ubuntu-repository-cache/+git/ubuntu-repository-cache/+merge/430417
Reviewed-by: Loïc Gomez <[email protected]>
| -rw-r--r-- | lib/ubuntu_repository_cache/metadata_cleanup.py | 21 | ||||
| -rw-r--r-- | lib/ubuntu_repository_cache/metadata_peers_sync.py | 21 |
2 files changed, 14 insertions, 28 deletions
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' REPO_SYNC_LOG = os.path.join(REPO_SYNC_DIR, 'metadata-cleanup.log') -SEMAPHORE_FILE = '/tmp/metadata-cleanup-running' - - def main(environment, log): apache_root = environment['APACHE_ROOT'] clean_metadata_dir(apache_root, log) @@ -42,14 +39,10 @@ if __name__ == "__main__": environment = os.environ start_time = time.time() - try: - with util.FileSemaphore(SEMAPHORE_FILE): - cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__") - main(environment, cache_logger.info) - cache_logger.info("Metadata cleanup from __main__ ended.") - - duration = time.time() - start_time - metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration' - util.send_to_influx(util.render_influx(metric_name, '', duration)) - except util.SemaphoreExistsError: - cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE)) + cache_logger.info("Metadata cleanup started from metadata_cleanup.py:__main__") + main(environment, cache_logger.info) + cache_logger.info("Metadata cleanup from __main__ ended.") + + duration = time.time() - start_time + metric_name = 'ubuntu_repository_cache_metadata_cleanup_duration' + util.send_to_influx(util.render_influx(metric_name, '', duration)) 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 from . import util -SEMAPHORE_FILE = '/tmp/metadata-peers-sync-running' - - def parse_config(conf=service.CONFIG_PATH): keys = {} cmd = ['bash', '-c', "trap 'env -0' exit; source {} > /dev/null 2>&1".format(conf)] @@ -104,14 +101,10 @@ if __name__ == "__main__": environment = os.environ start_time = time.time() - try: - with util.FileSemaphore(SEMAPHORE_FILE): - cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__") - ubuntu_repository_cache_sync(environment, cache_logger.info) - cache_logger.info("Metadata peers sync from __main__ ended.") - - duration = time.time() - start_time - metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration' - util.send_to_influx(util.render_influx(metric_name, '', duration)) - except util.SemaphoreExistsError: - cache_logger.info("Can't acquire semaphore: {} already exists.".format(SEMAPHORE_FILE)) + cache_logger.info("Metadata peers sync started from metadata_peers_sync.py:__main__") + ubuntu_repository_cache_sync(environment, cache_logger.info) + cache_logger.info("Metadata peers sync from __main__ ended.") + + duration = time.time() - start_time + metric_name = 'ubuntu_repository_cache_metadata_peers_sync_duration' + util.send_to_influx(util.render_influx(metric_name, '', duration)) |
