diff --git a/kcl/alluxio/posix_read/pipeline.yaml b/kcl/alluxio/posix_read/pipeline.yaml index 815ae617a1..dedf020174 100755 --- a/kcl/alluxio/posix_read/pipeline.yaml +++ b/kcl/alluxio/posix_read/pipeline.yaml @@ -3462,6 +3462,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -3469,9 +3499,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } @@ -3538,6 +3574,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -3545,9 +3611,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } diff --git a/kcl/alluxio/s3_read/pipeline.yaml b/kcl/alluxio/s3_read/pipeline.yaml index 8da634adc4..495fe5052f 100755 --- a/kcl/alluxio/s3_read/pipeline.yaml +++ b/kcl/alluxio/s3_read/pipeline.yaml @@ -565,6 +565,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -572,9 +602,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } @@ -641,6 +677,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -648,9 +714,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } @@ -714,6 +786,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -721,9 +823,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } @@ -787,6 +895,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -794,9 +932,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } diff --git a/kcl/alluxio/warp/pipeline.yaml b/kcl/alluxio/warp/pipeline.yaml index 32e8f13ae3..4e2646b87c 100644 --- a/kcl/alluxio/warp/pipeline.yaml +++ b/kcl/alluxio/warp/pipeline.yaml @@ -479,6 +479,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -486,9 +516,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } @@ -555,6 +591,36 @@ jobs: require_secret() { [[ -n "${!1:-}" && "${!1}" != '$('* ]] || fail "Required secret pipeline variable $1 is missing" } + resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi + } wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -562,9 +628,15 @@ jobs: "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done } diff --git a/kcl/lib/steps/alluxio/utils.k b/kcl/lib/steps/alluxio/utils.k index e75a5fd3d2..91a20d73cb 100644 --- a/kcl/lib/steps/alluxio/utils.k +++ b/kcl/lib/steps/alluxio/utils.k @@ -47,6 +47,36 @@ require_secret() { ResourceCommands = lambda workDir: str -> str { SecretCommands(workDir) + """ +resource_failure_details() { + local kind="$1" name="$2" pods pod + # Project status only: the resource spec and annotations can contain the license or SAS. + if ! kubectl get "$kind" "$name" -n alx-ns -o json | + jq '{ + name: .metadata.name, + status: (.status | {phase, state, reason, message, error, conditions}) + } | walk(if type == "string" then + reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join("")) + else . end)' | redact >&2; then + echo "Could not collect status for $kind/$name" >&2 + fi + if [[ "$kind" == license ]]; then + if ! pods="$(kubectl get pods -n alluxio-operator -o json | + jq -r '.items[] | select(.metadata.name | startswith("alluxio-license-controller-")) | .metadata.name')"; then + echo "Could not list the license-controller pods" >&2 + return 0 + fi + [[ -n "$pods" ]] || echo "No license-controller pods found" >&2 + for pod in $pods; do + echo "Recent license-controller logs: $pod" >&2 + if ! kubectl logs -n alluxio-operator "$pod" --all-containers=true --tail=100 --since=10m | + jq -Rs -r 'reduce ([env.ALLUXIO_LICENSE_STRING, env.BLOB_SAS][] | select(. != null and . != "")) as $secret + (.; split($secret) | join(""))' | redact >&2; then + echo "Could not collect logs for $pod" >&2 + fi + done + fi +} wait_phase() { local kind="$1" name="$2" field="$3" expected="$4" phase deadline=$((SECONDS + 900)) while :; do @@ -54,9 +84,15 @@ wait_phase() { "$kind" "$name" -n alx-ns -o "jsonpath={.status.$field}")" [[ "$phase" != "$expected" ]] || return 0 case "$phase" in - Failed|Error|Terminated) fail "$kind/$name failed; inspect securely in cluster" ;; + Failed|Error|Terminated) + resource_failure_details "$kind" "$name" + fail "$kind/$name failed; see status and controller diagnostics above" + ;; esac - (( SECONDS < deadline )) || fail "$kind/$name did not reach $expected before timeout" + if (( SECONDS >= deadline )); then + resource_failure_details "$kind" "$name" + fail "$kind/$name did not reach $expected before timeout; see diagnostics above" + fi sleep 10 done }