From f0609538b2dcd06df1dbcab4eeb5701c212a3cb6 Mon Sep 17 00:00:00 2001 From: David Zager Date: Fri, 16 Aug 2024 11:00:47 -0400 Subject: [PATCH] :seedling: try to actually trap on ERR to debug (#375) Signed-off-by: David Zager --- .github/actions/install-tackle/action.yml | 6 ++++ hack/install-konveyor.sh | 1 + hack/install-tackle.sh | 41 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/.github/actions/install-tackle/action.yml b/.github/actions/install-tackle/action.yml index 8102c37..7c06495 100644 --- a/.github/actions/install-tackle/action.yml +++ b/.github/actions/install-tackle/action.yml @@ -63,3 +63,9 @@ runs: make install-tackle working-directory: ${{ github.action_path }}/../../.. shell: bash + - name: Upload logs on fail + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: debug-output + path: /tmp/konveyor-debug diff --git a/hack/install-konveyor.sh b/hack/install-konveyor.sh index d5b6b5e..03b5bf5 100755 --- a/hack/install-konveyor.sh +++ b/hack/install-konveyor.sh @@ -1,5 +1,6 @@ #!/bin/bash +set -E set -e set -x set -o pipefail diff --git a/hack/install-tackle.sh b/hack/install-tackle.sh index 41ee97a..c8b4342 100755 --- a/hack/install-tackle.sh +++ b/hack/install-tackle.sh @@ -1,5 +1,6 @@ #!/bin/bash +set -E set -e set -x @@ -45,6 +46,46 @@ if ! command -v operator-sdk1 >/dev/null 2>&1; then chmod +x "${operator_sdk_bin}" fi +debug() { + set +e + echo "Install Konveyor FAILED!!!" + echo "What follows is some info that may be useful in debugging the failure" + + if [ "${CI}" == "true" ]; then + debug_output="/tmp/konveyor-debug" + mkdir -p "${debug_output}" + namespace="${debug_output}/namespace.yaml" + all="${debug_output}/all_resources.yaml" + operator="${debug_output}/operator_resources.yaml" + tackle="${debug_output}/tackle.yaml" + pods="${debug_output}/pod_descriptions.yaml" + + kubectl get namespace "${NAMESPACE}" -o yaml | tee "${namespace}" + kubectl get --namespace "${NAMESPACE}" all | tee "${all}" + kubectl get --namespace "${NAMESPACE}" -o yaml \ + subscriptions.operators.coreos.com,catalogsources.operators.coreos.com,installplans.operators.coreos.com,clusterserviceversions.operators.coreos.com | tee "${operator}" + kubectl get --namespace "${NAMESPACE}" -o yaml tackles.tackle.konveyor.io/tackle | tee "${tackle}" + + for pod in $(kubectl get pods -n "${NAMESPACE}" -o jsonpath='{.items[*].metadata.name}'); do + kubectl --namespace "${NAMESPACE}" describe pod "${pod}" | tee -a "${pods}" + kubectl --namespace "${NAMESPACE}" logs "${pod}" | tee "${debug_output}/${pod}.log" + done + else + kubectl get namespace "${NAMESPACE}" -o yaml + kubectl get --namespace "${NAMESPACE}" all + kubectl get --namespace "${NAMESPACE}" -o yaml \ + subscriptions.operators.coreos.com,catalogsources.operators.coreos.com,installplans.operators.coreos.com,clusterserviceversions.operators.coreos.com + kubectl get --namespace "${NAMESPACE}" -o yaml tackles.tackle.konveyor.io/tackle + + for pod in $(kubectl get pods -n "${NAMESPACE}" -o jsonpath='{.items[*].metadata.name}'); do + kubectl --namespace "${NAMESPACE}" describe pod "${pod}" + done + fi + + exit 1 +} +trap 'debug' ERR + install_operator() { kubectl auth can-i create namespace --all-namespaces kubectl create namespace ${NAMESPACE} || true