Merge lp:~maxiberta/ols-jenkaas/periodically-cleanup-old-running-lxcs into lp:~ols-jenkaas-admins/ols-jenkaas/trunk

Proposed by Maximiliano Bertacchini
Status: Merged
Merged at revision: 779
Proposed branch: lp:~maxiberta/ols-jenkaas/periodically-cleanup-old-running-lxcs
Merge into: lp:~ols-jenkaas-admins/ols-jenkaas/trunk
Diff against target: 31 lines (+19/-0)
2 files modified
jobs/ols-jenkaas.yaml (+10/-0)
slave/stop-old-lxcs (+9/-0)
To merge this branch: bzr merge lp:~maxiberta/ols-jenkaas/periodically-cleanup-old-running-lxcs
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Review via email: mp+398737@code.launchpad.net

Commit message

Add daily job to clean up lxcs older than 1d

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jobs/ols-jenkaas.yaml'
2--- jobs/ols-jenkaas.yaml 2020-07-07 13:02:51 +0000
3+++ jobs/ols-jenkaas.yaml 2021-02-25 19:20:21 +0000
4@@ -85,3 +85,13 @@
5 node: '{slave}'
6 builders:
7 - shell: annotate-output ~/jenkaas/slave/lxc-test
8+
9+- job-template:
10+ name: 'ols-jenkaas-stop-old-lxcs-{slave}'
11+ description: 'Stop old running lxcs in {slave}'
12+ project-type: freestyle
13+ node: '{slave}'
14+ builders:
15+ - shell: annotate-output ~/jenkaas/slave/stop-old-lxcs
16+ triggers:
17+ - timed: '0 4 * * *'
18
19=== added file 'slave/stop-old-lxcs'
20--- slave/stop-old-lxcs 1970-01-01 00:00:00 +0000
21+++ slave/stop-old-lxcs 2021-02-25 19:20:21 +0000
22@@ -0,0 +1,9 @@
23+#!/bin/sh -ex
24+
25+echo "Running containers: "
26+lxc ls | grep RUNNING | cut -d " " -f 2
27+
28+for NAME in $(lxc ls | grep RUNNING | cut -d" " -f2)
29+do
30+ lxc exec $NAME -- uptime | grep -qe "up [0-9]* day" && echo "Stopping $NAME..." && lxc stop $NAME
31+done

Subscribers

People subscribed via source and target branches