Merge ~hloeung/apt-stresstest-charm:chdist into apt-stresstest-charm:master

Proposed by Haw Loeung
Status: Merged
Approved by: Thomas Cuthbert
Approved revision: dbcfcb6e4c54e9109b9c2bdb196be74088ca3f21
Merged at revision: efcc9884f1b0430b8785f9e3c3b57d9acd937b39
Proposed branch: ~hloeung/apt-stresstest-charm:chdist
Merge into: apt-stresstest-charm:master
Diff against target: 37 lines (+8/-0)
2 files modified
files/test_apt_mirrors.py (+5/-0)
reactive/apt_stresstest.py (+3/-0)
Reviewer Review Type Date Requested Status
Thomas Cuthbert (community) Approve
Canonical IS Reviewers Pending
Review via email: mp+398180@code.launchpad.net

Commit message

Cleanup older chdist directories - LP:1915791

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
Thomas Cuthbert (tcuthbert) wrote :

LGTM +1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision efcc9884f1b0430b8785f9e3c3b57d9acd937b39

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/files/test_apt_mirrors.py b/files/test_apt_mirrors.py
2index 621b592..257d31c 100755
3--- a/files/test_apt_mirrors.py
4+++ b/files/test_apt_mirrors.py
5@@ -25,6 +25,7 @@ import socket
6 import subprocess
7 import sys
8 import tempfile
9+import time
10
11 from yaml import safe_load
12
13@@ -238,6 +239,10 @@ def chdist_create(domain, ip, series=None, data_dir=None):
14 chdist = '{}-{}-{}'.format(domain, ip, series)
15 source_uri = 'http://{}/ubuntu'.format(ip)
16 if os.path.exists(get_chdist_config_path(chdist, data_dir)):
17+ # Update the timestamp of chdist directories, this lets the
18+ # cron job clean up older unused ones.
19+ now = time.time()
20+ os.utime(os.path.join(data_dir, chdist), (now, now))
21 return False
22 cmd = ['chdist', '-d', data_dir, 'create', chdist, source_uri, series, 'main', 'universe']
23 subprocess.call(cmd, stdout=subprocess.DEVNULL)
24diff --git a/reactive/apt_stresstest.py b/reactive/apt_stresstest.py
25index 3655300..55893ba 100644
26--- a/reactive/apt_stresstest.py
27+++ b/reactive/apt_stresstest.py
28@@ -36,6 +36,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
29
30 # Clean up left over downloads from previous test. This is likely due to hitting the run timeout.
31 */10 * * * * {user} find /tmp -maxdepth 1 -type d -name 'apt-stresstest-*' -mmin +{cleanup_time} -exec rm -rf {{}} +
32+# Clean up older unused chdists.
33+1 1 * * * {user} find ~{user}/.chdist -maxdepth 1 -mindepth 1 -type d -mtime +1 -exec rm -rf {{}} +
34+
35 """ # NOQA: E501
36
37 LOGFILE = '/var/log/apt-stresstest.log'

Subscribers

People subscribed via source and target branches