Skip to content

Commit 9b5086c

Browse files
committed
Destroy CI clusters when there is no active investigation
To prevent too many resources from being consumed, keeping the cluster is not the default action. If a developer wants to investigate, they need to connect to a pod and remove the 'destroy_cluster.txt' file located at the root of the source directory. Signed-off-by: Romain Arnaud <[email protected]>
1 parent a976d03 commit 9b5086c

File tree

7 files changed

+26
-24
lines changed

7 files changed

+26
-24
lines changed

.tekton/pipeline/acceptance-tests.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ spec:
115115
- input: "$(tasks.deploy-cluster.status)"
116116
operator: notin
117117
values: ["None"]
118-
- input: "$(tasks.plnsvc-setup.status)"
119-
operator: notin
120-
values: ["Failed"]
121-
- input: "$(tasks.pipeline-service-tests.status)"
122-
operator: notin
123-
values: ["Failed"]
124118
params:
125119
- name: cluster-name
126120
value: "$(tasks.generate-cluster-name.results.cluster-name)"

.tekton/pipeline/upgrade-tests.yaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,6 @@ spec:
188188
- input: "$(tasks.deploy-cluster.status)"
189189
operator: notin
190190
values: ["None"]
191-
- input: "$(tasks.plnsvc-setup.status)"
192-
operator: notin
193-
values: ["Failed"]
194-
- input: "$(tasks.tests-before-upgrade.status)"
195-
operator: notin
196-
values: ["Failed"]
197-
- input: "$(tasks.plnsvc-upgrade-setup.status)"
198-
operator: notin
199-
values: ["Failed"]
200-
- input: "$(tasks.tests-post-upgrade.status)"
201-
operator: notin
202-
values: ["Failed"]
203-
- input: "$(tasks.plnsvc-downgrade-setup.status)"
204-
operator: notin
205-
values: ["Failed"]
206-
- input: "$(tasks.tests-post-downgrade.status)"
207-
operator: notin
208-
values: ["Failed"]
209191
params:
210192
- name: cluster-name
211193
value: "$(tasks.generate-cluster-name.results.cluster-name)"

.tekton/tasks/destroy-cluster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ spec:
3333
secretKeyRef:
3434
name: hypershift-bitwarden
3535
key: "BW_PASSWORD"
36+
workingDir: "$(workspaces.source.path)"
3637
command:
3738
- $(workspaces.source.path)/ci/images/ci-runner/hack/bin/destroy-cluster.sh

ci/docs/continuous_integation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ After that, you need to add a Configmap for storing the kubeconfig of ROSA clust
2222
## Setup GitHub app
2323

2424
- Need to configure GitHub app for Pipelines as Code configuration into Pipeline Service repository.
25+
26+
## Debugging an issue during the CI execution
27+
The CI will destroy the test cluster at the end of the pipeline by default.
28+
This is an issue when troubleshooting is required.
29+
30+
To bypass deletion of the test cluster, delete the `destroy-cluster.txt` file in created in the root of the cloned repository.
31+
There is a 15 minutes window to log onto the container running the `destroy-cluster` step and delete the file.

ci/images/ci-runner/hack/bin/destroy-cluster.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ SCRIPT_DIR="$(
99
pwd
1010
)"
1111

12+
# Give developers 15mins to connect to a pod and remove the file
13+
# if they want to investigate the failure
14+
if [ -e "$PWD/destroy-cluster.txt" ]; then
15+
sleep 900
16+
if [ -e "$PWD/destroy-cluster.txt" ]; then
17+
echo "Failure is not being investigated, cluster will be destroyed."
18+
else
19+
echo "Failure under investigation, cluster will not be destroyed."
20+
exit 1
21+
fi
22+
fi
23+
1224
# shellcheck source=ci/images/ci-runner/hack/bin/utils.sh
1325
source "$SCRIPT_DIR/utils.sh"
1426

ci/images/ci-runner/hack/bin/run-plnsvc-setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -o nounset
44
set -o pipefail
55
set -x
66

7+
# Create a file that will prevent the cluster deletion in case tests are failing
8+
touch "$PWD/destroy-cluster.txt"
9+
710
echo "Execute dev_setup.sh script to set up pipeline-service ..."
811
kubectl -n default exec pod/ci-runner -- \
912
sh -c "/source/ci/images/ci-runner/hack/sidecar/bin/plnsvc_setup.sh $REPO_URL $REPO_REVISION"

ci/images/ci-runner/hack/bin/run-tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ set -x
77
echo "Execute test.sh script to verify pipeline-service ..."
88
kubectl -n default exec pod/ci-runner -- \
99
sh -c "/source/ci/images/ci-runner/hack/sidecar/bin/plnsvc_test.sh"
10+
11+
# If the tests are successful, the cluster can be destroyed right away
12+
rm "$PWD/destroy-cluster.txt"

0 commit comments

Comments
 (0)