38
38
type : boolean
39
39
required : false
40
40
default : true
41
- scan- push :
41
+ push-dirty :
42
42
description : Push scanned images that have vulnerabilities?
43
43
type : boolean
44
44
required : false
45
+ # NOTE(Alex-Welsh): This default should be flipped once we resolve existing failures
45
46
default : true
46
47
47
48
env :
@@ -171,11 +172,14 @@ jobs:
171
172
env :
172
173
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
173
174
175
+ - name : Create build logs output directory
176
+ run : mkdir image-build-logs
177
+
174
178
- name : Build kolla overcloud images
175
179
id : build_overcloud_images
176
180
continue-on-error : true
177
181
run : |
178
- args="${{ github.event. inputs.regexes }}"
182
+ args="${{ inputs.regexes }}"
179
183
args="$args -e kolla_base_distro=${{ matrix.distro }}"
180
184
args="$args -e kolla_tag=${{ needs.generate-tag.outputs.kolla_tag }}"
181
185
args="$args -e stackhpc_repo_mirror_auth_proxy_enabled=true"
@@ -184,7 +188,11 @@ jobs:
184
188
kayobe overcloud container image build $args
185
189
env :
186
190
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
187
- if : github.event.inputs.overcloud == 'true'
191
+ if : inputs.overcloud
192
+
193
+ - name : Copy overcloud container image build logs to output directory
194
+ run : mv /var/log/kolla-build.log image-build-logs/kolla-build-overcloud.log
195
+ if : inputs.overcloud
188
196
189
197
- name : Build kolla seed images
190
198
id : build_seed_images
@@ -198,7 +206,11 @@ jobs:
198
206
kayobe seed container image build $args
199
207
env :
200
208
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
201
- if : github.event.inputs.seed == 'true'
209
+ if : inputs.seed
210
+
211
+ - name : Copy seed container image build logs to output directory
212
+ run : mv /var/log/kolla-build.log image-build-logs/kolla-build-seed.log
213
+ if : inputs.seed
202
214
203
215
- name : Get built container images
204
216
run : |
@@ -208,57 +220,74 @@ jobs:
208
220
run : if [ $(wc -l < ${{ matrix.distro }}-container-images) -le 1 ]; then exit 1; fi
209
221
210
222
- name : Scan built container images
211
- run : src/kayobe-config/tools/scan-images.sh ${{ matrix.distro }} ${{ needs.generate-tag.outputs.kolla_tag }}
212
-
213
- - name : Upload Trivy scan results artifact
214
- uses : actions/upload-artifact@v4
215
- with :
216
- name : ${{ matrix.distro }}-image-scan-output
217
- path : image-scan-output
218
- retention-days : 7
223
+ run : |
224
+ src/kayobe-config/tools/scan-images.sh ${{ matrix.distro }} ${{ needs.generate-tag.outputs.kolla_tag }}
219
225
220
226
- name : Fail if no images have passed scanning
221
227
run : if [ $(wc -l < image-scan-output/clean-images.txt) -le 0 ]; then exit 1; fi
222
- if : github.event.inputs.scan-push == 'false'
228
+ if : ${{ !inputs.push-dirty }}
229
+
230
+ - name : Copy clean images to push-attempt-images list
231
+ run : cp image-scan-output/clean-images.txt image-scan-output/push-attempt-images.txt
223
232
224
- - name : Append dirty images to clean list
233
+ - name : Append dirty images to push list
225
234
run : |
226
- cat image-scan-output/dirty-images.txt >> image-scan-output/clean -images.txt
227
- if : github.event. inputs.scan- push == 'true'
235
+ cat image-scan-output/dirty-images.txt >> image-scan-output/push-attempt -images.txt
236
+ if : inputs.push-dirty
228
237
229
238
- name : Push images
230
239
run : |
240
+ touch image-scan-output/push-failed-images.txt
231
241
source venvs/kayobe/bin/activate &&
232
242
source src/kayobe-config/kayobe-env --environment ci-builder &&
233
243
kayobe playbook run ${KAYOBE_CONFIG_PATH}/ansible/docker-registry-login.yml &&
234
244
235
245
while read -r image; do
236
246
# Retries!
237
- for i in {1..10}; do
238
- docker push ${image} && break || sleep 5
247
+ for i in {1..5}; do
248
+ if docker push $image; then
249
+ echo "Pushed $image"
250
+ break
251
+ elif $i == 5; then
252
+ echo "Failed to push $image"
253
+ echo $image >> image-scan-output/push-failed-images.txt
254
+ else
255
+ echo "Failed on retry $i"
256
+ sleep 5
257
+ fi;
239
258
done
240
- done < image-scan-output/clean-images.txt
259
+ done < image-scan-output/push-attempt-images.txt &&
260
+ mv image-scan-output image-build-logs/image-scan-output
241
261
shell : bash
242
262
env :
243
263
KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
244
- if : github.event. inputs.push == 'true'
264
+ if : inputs.push
245
265
246
- - name : Upload pushed container images artifact
266
+ - name : Upload output artifact
247
267
uses : actions/upload-artifact@v4
248
268
with :
249
- name : ${{ matrix.distro }}-pushed-container-images
250
- path : image-scan-output/clean-images.txt
269
+ name : ${{ matrix.distro }}-logs
270
+ path : image-build-logs
251
271
retention-days : 7
272
+ if : ${{ !cancelled() }}
252
273
253
274
- name : Fail when images failed to build
254
- run : exit 1
255
- if : steps.build_overcloud_images.outcome == 'failure' || steps.build_seed_images.outcome == 'failure'
275
+ run : echo "An image build failed. Check the workflow artifact for build logs" && exit 1
276
+ if : ${{ steps.build_overcloud_images.outcome == 'failure' || steps.build_seed_images.outcome == 'failure' }}
277
+
278
+ - name : Fail when images failed to push
279
+ run : if [ $(wc -l < image-build-logs/push-failed-images.txt) -gt 0 ]; then cat image-build-logs/push-failed-images.txt && exit 1; fi
280
+ if : ${{ !cancelled() }}
281
+
282
+ - name : Fail when images failed scanning
283
+ run : if [ $(wc -l < image-build-logs/dirty-images.txt) -gt 0 ]; then cat image-build-logs/dirty-images.txt && exit 1; fi
284
+ if : ${{ !inputs.push-dirty && !cancelled() }}
256
285
257
286
sync-container-repositories :
258
287
name : Trigger container image repository sync
259
288
needs :
260
289
- container-image-build
261
- if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push == 'true'
290
+ if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push
262
291
runs-on : ubuntu-latest
263
292
permissions : {}
264
293
steps :
@@ -267,7 +296,7 @@ jobs:
267
296
- name : Trigger container image repository sync
268
297
run : |
269
298
filter='${{ inputs.regexes }}'
270
- if [[ -n $filter ]] && [[ ${{ github.event. inputs.seed }} == 'true' ]]; then
299
+ if [[ -n $filter ]] && [[ ${{ inputs.seed }} == 'true' ]]; then
271
300
filter="$filter bifrost"
272
301
fi
273
302
gh workflow run \
0 commit comments