Skip to content

Commit

Permalink
fix: don't fail cleanup if internalrequests not installed
Browse files Browse the repository at this point in the history
This is the case on the new Fedora Cluster run by the Konflux+Fedora SIG

Signed-off-by: Ralph Bean <rbean@redhat.com>
  • Loading branch information
ralphbean authored and johnbieren committed Nov 8, 2024
1 parent 545fba8 commit 5cde5cf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions tasks/cleanup-workspace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Tekton task to delete a given directory in a passed workspace and cleanup Intern
| delay | Time in seconds to delay execution. Needed to allow other finally tasks to access workspace before being deleted | Yes | 60 |
| pipelineRunUid | The uid of the current pipelineRun. It is only available at the pipeline level | Yes | "" |

## Changes in 0.8.2
* Fix error if internalrequests are not installed on cluster

## Changes in 0.8.1
* Fix linting issues in this task

Expand Down
12 changes: 8 additions & 4 deletions tasks/cleanup-workspace/cleanup-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Task
metadata:
name: cleanup-workspace
labels:
app.kubernetes.io/version: "0.8.1"
app.kubernetes.io/version: "0.8.2"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: release
Expand Down Expand Up @@ -34,9 +34,13 @@ spec:
set -eux
if [ -n "$(params.pipelineRunUid)" ] ; then
# Cleanup all internalrequests
kubectl delete internalrequest \
-l internal-services.appstudio.openshift.io/pipelinerun-uid="$(params.pipelineRunUid)"
# Cleanup all internalrequests, but only if internalrequests exist on cluster
if kubectl api-resources | grep InternalRequest | grep appstudio.redhat.com ; then
kubectl delete internalrequest \
-l internal-services.appstudio.openshift.io/pipelinerun-uid="$(params.pipelineRunUid)"
else
echo "CRD internalrequests.appstudio.redhat.com not found on cluster"
fi
fi
if [ -z "$(params.subdirectory)" ] ; then
Expand Down

0 comments on commit 5cde5cf

Please sign in to comment.