Skip to content

Commit

Permalink
Fix gather_nodes execution with multiple images (#215)
Browse files Browse the repository at this point in the history
POD_NAME is already available out of the box as
an env variable via downwardAPIs, no need to introspect
it from the list of running pods.
POD_NAME introspection is currently broken when
multiple images are executed in parallel.

Signed-off-by: Simone Tiraboschi <[email protected]>
  • Loading branch information
tiraboschi authored May 28, 2024
1 parent 54e97fd commit dcab06c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion collection-scripts/gather_nodes
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ DAEMONSET_MANIFEST="${MANIFEST_PATH}/node-gather-ds.yaml"

if [[ -z ${MUST_GATHER_IMAGE} ]]; then
NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
POD_NAME=$(oc get pods -l app=must-gather -n "$NAMESPACE" -o'custom-columns=name:metadata.name' --no-headers)
MUST_GATHER_IMAGE=${MUST_GATHER_IMAGE:-$(oc get pod -n "$NAMESPACE" "$POD_NAME" -o jsonpath="{.spec.containers[0].image}")}
fi

Expand Down
3 changes: 1 addition & 2 deletions collection-scripts/logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ NAMESPACE_FILE=/var/run/secrets/kubernetes.io/serviceaccount/namespace

# if running in a pod
if [[ -f ${NAMESPACE_FILE} ]]; then
POD=$(oc status | grep "^pod" | sed -E "s|pod/([^ ]+).*|\1|")
oc logs --timestamps=true -n "$(cat ${NAMESPACE_FILE})" "${POD}" -c gather > "${BASE_COLLECTION_PATH}/must-gather.log"
oc logs --timestamps=true -n "$(cat ${NAMESPACE_FILE})" "${POD_NAME}" -c gather > "${BASE_COLLECTION_PATH}/must-gather.log"
fi

0 comments on commit dcab06c

Please sign in to comment.