-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathz-clean-resources-gce.yml
54 lines (49 loc) · 1.82 KB
/
z-clean-resources-gce.yml
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
- job:
name: 'z-clean-resources-gce'
description: Clean up old instances and firewall rules.
builders:
- get-gce-creds
- get-gce-cleanup-scripts
- shell: |-
#!/bin/bash
set -eu
# Display instances' regions
python3 $SCRIPTS_DIR/gce.py -v list-instances juju-*
python3 $SCRIPTS_DIR/gce.py -v delete-instances -o 2 juju-*
gcloud auth activate-service-account --key-file=$GCE_CREDENTIALS_FILE
gcloud config set project gothic-list-89514
gcloud compute firewall-rules list
# TODO - we no longer store state between jobs invocations.
# We need a new way to delete stale filewall rules.
# On every job run, remove any rules that still exist from last run
# generate gce rules with
# gcloud compute firewall-rules list | awk {'print $1'} | grep juju > ~/gcerules
gcloud compute firewall-rules list | awk {'print $1'} | grep juju | sort -u > newrules
# destroy all rules still found
comm -1 -2 ~/gcerules newrules | xargs -I % gcloud compute firewall-rules delete % --quiet
# set new rules
mv newrules ~/gcerules
node: ephemeral-noble-small-amd64
publishers:
- email-ext:
recipients: juju-qa-aws@canonical.com
content-type: html
attach-build-log: false
fixed-unhealthy: true
first-failure: false
second-failure: true
body: |
<h1>Infrastructure failure: gce</h1>
The following job has repeatedly failed.
<br />
Please login to jenkins job <pre>`z-clean-resources-gce`</pre> to find out why
it is failing.
<br />
$DEFAULT_CONTENT
triggers:
- timed: H */2 * * *
wrappers:
- timeout:
fail: true
timeout: 30
type: absolute