From a97c1e4089a8f97e184019c758e64b9225af857b Mon Sep 17 00:00:00 2001 From: Martin Basti Date: Fri, 13 Dec 2024 20:59:38 +0100 Subject: [PATCH] fix(prefetch): fail step when error happen Task were failing silently causing harder to debug errors or misleding users that different step failed. Ensure that steps aren't failing silently and we don't run unnecessary steps after failure. Signed-off-by: Martin Basti --- .../0.1/prefetch-dependencies-oci-ta.yaml | 12 ++++++++++++ .../0.1/prefetch-dependencies.yaml | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml b/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml index 87deeb25b5..0f93079a73 100644 --- a/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml +++ b/task/prefetch-dependencies-oci-ta/0.1/prefetch-dependencies-oci-ta.yaml @@ -151,6 +151,8 @@ spec: - name: sanitize-cachi2-config-file-with-yq image: quay.io/konflux-ci/yq:latest@sha256:343c2ca0a347ae87fe43750ee0873e1fe813f77eff56e9722c840bb75d97fef2 script: | + set -euo pipefail + if [ -n "${CONFIG_FILE_CONTENT}" ]; then # we need to drop 'goproxy_url' for safety reasons until cachi2 decides what the SBOM # impact of this configuration option will be: @@ -163,6 +165,8 @@ spec: - name: INPUT value: $(params.input) script: | + set -euo pipefail + if [ -z "${INPUT}" ]; then # Confirm input was provided though it's likely the whole task would be skipped if it wasn't echo "No prefetch will be performed because no input was provided for cachi2 fetch-deps" @@ -183,6 +187,9 @@ spec: value: $(params.ACTIVATION_KEY) script: | #!/bin/bash + + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0 @@ -325,6 +332,8 @@ spec: script: | #!/bin/bash + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0 @@ -398,6 +407,9 @@ spec: image: quay.io/redhat-appstudio/cachi2:0.15.0@sha256:b141cb5cf4d98e6c5f668f1fe172e1d68f2a44ac1027403fbcff94ce1e68185d script: | #!/bin/bash + + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0 diff --git a/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml b/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml index 9a859d42de..2a4061c265 100644 --- a/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml +++ b/task/prefetch-dependencies/0.1/prefetch-dependencies.yaml @@ -71,6 +71,9 @@ spec: - name: sanitize-cachi2-config-file-with-yq image: quay.io/konflux-ci/yq:latest@sha256:343c2ca0a347ae87fe43750ee0873e1fe813f77eff56e9722c840bb75d97fef2 script: | + + set -euo pipefail + if [ -n "${CONFIG_FILE_CONTENT}" ] then # we need to drop 'goproxy_url' for safety reasons until cachi2 decides what the SBOM @@ -87,6 +90,9 @@ spec: - name: INPUT value: $(params.input) script: | + + set -euo pipefail + if [ -z "${INPUT}" ] then # Confirm input was provided though it's likely the whole task would be skipped if it wasn't @@ -109,6 +115,9 @@ spec: type: string script: | #!/bin/bash + + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0 @@ -258,6 +267,8 @@ spec: script: | #!/bin/bash + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0 @@ -334,6 +345,9 @@ spec: # the cluster will set imagePullPolicy to IfNotPresent script: | #!/bin/bash + + set -euo pipefail + if [ -f /shared/skip ]; then echo "Skipping." exit 0