aboutsummaryrefslogtreecommitdiff
path: root/tcwg-update-containers.yaml.in
blob: dcb71490eb9f5eeb55a20998908c3aef809cb15e (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include tcwg/default.yaml.inc

- job:
    name: tcwg-update-#{CONTAINER}-containers
    project-type: freestyle
    defaults: global
    properties:
        - authorization:
            anonymous:
                - job-read
                - job-extended-read
            linaro:
                - job-build
                - job-cancel
        - build-discarder:
            days-to-keep: 30
            num-to-keep: 100
        - throttle:
            max-per-node: 1
            option: project
    parameters:
        - label:
            name: nodes
#if CONTAINER_host
            default: tcwg && !tcwg-secondary-node
#elif CONTAINER_jenkins
            # We can't restart coordinator nodes because we can't block-out
            # matrix master jobs.  Similarly, we can't restart nodes with
            # multiple executors because we risk killing builds on other
            # executors.
            default: tcwg && !tcwg-coordinator && !tcwg-parallel-jobs
#elif CONTAINER_llvmbot || CONTAINER_buildkite
            default: tcwg-llvmbot
#elif CONTAINER_bmk
            default: tcwg-bmk-hw
#endif
            all-nodes: true
            matching-label: 'allCases'
            description: 'Machines to run on'
        - string:
            name: distro
            default: 'focal'
            description: 'Distro version to use.'
#if CONTAINER_llvmbot
        - string:
            name: master
            default: 'normal'
            description: 'LLVM buildmaster to use: silent or normal'
#endif
        - bool:
            name: force
            default: 'false'
            description: 'Whether to force update even with no changes in image'
        - bool:
            name: verbose
            default: 'true'
            description: 'Whether to be verbose'
        - string:
            name: scripts_branch
            default: master
            description: 'Scripts revision to use'
    disabled: false
    node: tcwg-coordinator
    concurrent: true
    display-name: 'TCWG CCC Update #{CONTAINER} containers'
    # We need to unshare workspace with $NODE_NAME in the path to
    # correctly run on tcwg-bmk-* nodes.
    workspace: workspace/tcwg-update-#{CONTAINER}-containers_$EXECUTOR_NUMBER/$NODE_NAME
    scm:
      - jenkins-scripts
    triggers:
        - timed: '@daily'
    wrappers:
        - timeout:
            timeout: 600
        - timestamps
#if CONTAINER_llvmbot
        - credentials-binding:
            - text:
                credential-id: TCWG_LLVMBOT_PASSWORD
                variable: TCWG_LLVMBOT_PASSWORD
#elif CONTAINER_buildkite
        - credentials-binding:
            - text:
                credential-id: TCWG_BUILDKITE_TOKEN_LIBCXX
                variable: TCWG_BUILDKITE_TOKEN_LIBCXX
#elif CONTAINER_bmk
        - ssh-agent-credentials:
            users:
                - 'tcwg-benchmark'
#endif
        - build-name:
            name: '#${BUILD_NUMBER}-${NODE_NAME}'
    builders:
      - shell:
          command: |
            #!/bin/bash
            set -ex

#if CONTAINER_host
            case "$NODE_NAME" in
              tcwg-llvmbot_*) group=tcwg-llvm ;;
              *) group=all ;;
            esac
            ./jenkins-scripts/tcwg-update-host-containers.sh \
            --distro "$distro" \
            --group "$group" \
            --force "$force" \
            --verbose "$verbose"
#elif CONTAINER_jenkins
            ./jenkins-scripts/tcwg-update-host-containers.sh \
            --distro "$distro" \
            --node "$NODE_NAME" \
            --force "$force" \
            --verbose "$verbose" || exit 125
          unstable-return: 125
#elif CONTAINER_llvmbot
            ./jenkins-scripts/tcwg-update-llvmbot-containers.sh \
            --NODE_NAME "$NODE_NAME" \
            --distro "$distro" \
            --master "$master" \
            --password "$TCWG_LLVMBOT_PASSWORD" \
            --force "$force" \
            --verbose "$verbose"
#elif CONTAINER_buildkite
            ./jenkins-scripts/tcwg-update-llvmbot-containers.sh \
            --NODE_NAME "$NODE_NAME" \
            --distro "$distro" \
            --master "buildkite" \
            --password "$TCWG_BUILDKITE_TOKEN_LIBCXX" \
            --force "$force" \
            --verbose "$verbose"
#elif CONTAINER_bmk
            for lock in $(set +f; ls -tr $HOME/boards/$NODE_NAME-*.lock); do
              (
                flock -e 9
                touch $lock
                board=$(cat <&9)
                rsync -az --delete ./jenkins-scripts/ $board:jenkins-scripts/
                node=$(echo "$board" \
                         | sed -e "s/tcwg-bmk-/tcwg-/" -e "s/\.tcwglab\$//")
                ssh -Snone $board ./jenkins-scripts/tcwg-update-host-containers.sh \
                  --distro "$distro" \
                  --force "$force" \
                  --verbose "$verbose"
                ssh -Snone $board ./jenkins-scripts/tcwg-update-host-containers.sh \
                  --distro "$distro" \
                  --node "$node" \
                  --force "$force" \
                  --verbose "$verbose"

                # We start the jenkins container above so that it can process
                # all the queued cleanup and maintenance tasks.
                # Here we wait for jenkins container to become idle by looking
                # at number of processes.  Idle container has
                # - HEADER
                # - tini
                # - sudo java
                # - java
                # processes -- 4 lines.
                while sleep 60; do
                  if [ "$(ssh -Snone $board docker top $node | wc -l)" -le "4" ]; then
                    break
                  fi
                done

                # Now stop the jenkins container so that it's not terminated
                # midway some other build by a starting benchmarking job.
                ssh -Snone $board docker stop "$node"
              ) 9<$lock &
            done
            wait
#endif