aboutsummaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.yaml
blob: 8e07572d3077fbb62a198bab01d198582b5c6ab0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- job:
    name: tcwg-cleanup-stale-containers
    project-type: matrix
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 30
        - throttle:
            max-per-node: 1
            option: project
    parameters:
        - string:
            name: slave_list
            default: 'tcwg-apm-01 tcwg-apm-02 tcwg-apm-03 tcwg-apm-04 tcwg-tx1-01 tcwg-tx1-02 tcwg-tx1-03 tcwg-tx1-04 tcwg-tx1-05 tcwg-x86_64-build-01 tcwg-x86_64-build-02 tcwg-x86_64-build-03 tcwg-x86_64-build-04 tcwg-x86_64-build-05 tcwg-x86_64-build-06 tcwg-x86_64-build-07 tcwg-x86_64-build-08 tcwg-x86_64-dev-01 tcwg-x86_64-dev-02 tcwg-bmk-dev-01 tcwg-bmk-dev-02'
            description: 'List of slaves to run on -- should be a subset of slave axis'
        - string:
            name: cleanup_running_hours
            default: '10'
            description: 'Delete containers that are more then "hours" old.  Use "0" to disable time check.  Use negative values for dry-run.'
        - string:
            name: cleanup_stopped_hours
            default: '240'
            description: 'Delete containers that are more then "hours" old.  Use "0" to disable the cleanup.  Use negative values for dry-run.'
        - string:
            name: cleanup_ssh_agent_hours
            default: '48'
            description: 'Kill ssh-agent processes that are more then "hours" old.  Use "0" to disable time check.'
        - bool:
            name: cleanup_volumes
            default: 'false'
            description: 'Whether to cleanup dangling volumes'
        - bool:
            name: cleanup_images
            default: 'true'
            description: 'Whether to cleanup images'
        - bool:
            name: verbose
            default: 'false'
            description: 'Whether to be verbose'
        - string:
            name: scripts_branch
            default: refs/heads/master
            description: 'Scripts revision to use'
    disabled: false
    node: tcwg-coordinator
    concurrent: false
    display-name: 'TCWG CCC Cleanup stale containers'
    triggers:
        - timed: '@daily'
    scm:
        - git:
            url: https://git-us.linaro.org/toolchain/jenkins-scripts.git
            refspec: +refs/heads/*:refs/remotes/origin/* +refs/changes/*:refs/changes/*
            branches:
                - ${scripts_branch}
            skip-tag: true
            shallow-clone: true
            wipe-workspace: true
    axes:
        - axis:
            type: slave
            name: label
            values:
                - tcwg-apm-01
                - tcwg-apm-02
                - tcwg-apm-03
                - tcwg-apm-04
                - tcwg-tx1-01
                - tcwg-tx1-02
                - tcwg-tx1-03
                - tcwg-tx1-04
                - tcwg-tx1-05
                - tcwg-x86_64-build-01
                - tcwg-x86_64-build-02
                - tcwg-x86_64-build-03
                - tcwg-x86_64-build-04
                - tcwg-x86_64-build-05
                - tcwg-x86_64-build-06
                - tcwg-x86_64-build-07
                - tcwg-x86_64-build-08
                - tcwg-x86_64-dev-01
                - tcwg-x86_64-dev-02
                - tcwg-bmk-dev-01
                - tcwg-bmk-dev-02
        - axis:
            type: dynamic
            name: slave
            values:
                - slave_list
    execution-strategy:
        combination-filter: |
            label==slave
        sequential: false
    wrappers:
        - timeout:
            timeout: 600
        - timestamps
        - ssh-agent-credentials:
            # tcwg-buildslave user id
            users:
                - 'e0958a95-204f-4c14-a66c-5e2be6c5d50a'
        - build-name:
            name: '#${BUILD_NUMBER}'
    builders:
        - shell: |
            #!/bin/bash

            set -ex
            case "$label" in
              tcwg-bmk-dev-*)
                # tcwg-bmk-dev-* nodes are hosted on dev-* machines, aka
                # tcwg-x86_64-dev-* nodes.  We only need to cleanup ssh-agent
                # processes for tcwg-benchmark user, so disable all other
                # cleanups.
                ./tcwg-cleanup-stale-containers.sh --cleanup-running-hours 0 --cleanup-stopped-hours 0 --cleanup-ssh-agent-hours $cleanup_ssh_agent_hours --cleanup-volumes false --cleanup-images false --verbose $verbose || true
                ;;
              *)
                ./tcwg-cleanup-stale-containers.sh --cleanup-running-hours $cleanup_running_hours --cleanup-stopped-hours $cleanup_stopped_hours --cleanup-ssh-agent-hours $cleanup_ssh_agent_hours --cleanup-volumes $cleanup_volumes --cleanup-images $cleanup_images --verbose $verbose
                ;;
            esac
    publishers:
        - email:
            recipients: tcwg-validation@linaro.org