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
=== modified file 'jobs/ols-jenkaas.yaml'
--- jobs/ols-jenkaas.yaml 2020-07-07 13:02:51 +0000
+++ jobs/ols-jenkaas.yaml 2021-02-25 19:20:21 +0000
@@ -85,3 +85,13 @@
85 node: '{slave}'85 node: '{slave}'
86 builders:86 builders:
87 - shell: annotate-output ~/jenkaas/slave/lxc-test 87 - shell: annotate-output ~/jenkaas/slave/lxc-test
88
89- job-template:
90 name: 'ols-jenkaas-stop-old-lxcs-{slave}'
91 description: 'Stop old running lxcs in {slave}'
92 project-type: freestyle
93 node: '{slave}'
94 builders:
95 - shell: annotate-output ~/jenkaas/slave/stop-old-lxcs
96 triggers:
97 - timed: '0 4 * * *'
8898
=== added file 'slave/stop-old-lxcs'
--- slave/stop-old-lxcs 1970-01-01 00:00:00 +0000
+++ slave/stop-old-lxcs 2021-02-25 19:20:21 +0000
@@ -0,0 +1,9 @@
1#!/bin/sh -ex
2
3echo "Running containers: "
4lxc ls | grep RUNNING | cut -d " " -f 2
5
6for NAME in $(lxc ls | grep RUNNING | cut -d" " -f2)
7do
8 lxc exec $NAME -- uptime | grep -qe "up [0-9]* day" && echo "Stopping $NAME..." && lxc stop $NAME
9done

Subscribers

People subscribed via source and target branches