Skip to content

Commit fa31d1f

Browse files
[oadp-1.1] OADP-774 must-gather: add timeout to velero logs/describe, var typos, remove duplicate logs, add make run (#821)
* Typo shell variable * mustgather `make run` target Signed-off-by: Tiger Kaovilai <[email protected]> * do not gather restic logs twice Signed-off-by: Tiger Kaovilai <[email protected]> * force a timeout of velero command execution * Use value for timeout from $timeout Signed-off-by: Tiger Kaovilai <[email protected]> Co-authored-by: Tiger Kaovilai <[email protected]>
1 parent 8dce868 commit fa31d1f

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

must-gather/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ PROMETHEUS_DUMP_PATH ?= $(shell find ./must-gather.local* -name prom_data.tar.gz
88

99
build: docker-build docker-push
1010

11+
run: IMAGE_REGISTRY:=ttl.sh
12+
run: IMAGE_NAME:=oadp/must-gather-$(shell git rev-parse --short HEAD)-$(shell echo $$RANDOM)
13+
run: IMAGE_TAG:=1h
14+
run:
15+
IMAGE_REGISTRY=$(IMAGE_REGISTRY) IMAGE_NAME=$(IMAGE_NAME) IMAGE_TAG=$(IMAGE_TAG) make build && \
16+
oc adm must-gather --image ${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}
17+
1118
docker-build:
1219
docker build -t ${IMAGE_REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG} .
1320

must-gather/collection-scripts/logs/gather_logs_backup

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ skip_tls=$8
1515
mkdir -p "{object_collection_path}"
1616
echo "[cluster=${cluster}][ns=${ns}] Gathering 'velero backup describe ${backup}'"
1717
if [ "$timeout" = "0s" ]; then
18-
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero describe backup ${backup} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/backup-describe-${backup}.txt" &
18+
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout 30s /velero describe backup ${backup} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/backup-describe-${backup}.txt" &
1919
else
20-
oc -n ${ns} exec --request-timeout=${timeout} $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero describe backup ${backup} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/backup-describe-${backup}.txt" &
20+
oc -n ${ns} exec --request-timeout=${timeout} $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout ${timeout} /velero describe backup ${backup} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/backup-describe-${backup}.txt" &
2121
fi
2222
echo "[cluster=${cluster}][ns=${ns}] Gathering 'velero backup logs ${backup}'"
23-
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero backup logs ${backup} --insecure-skip-tls-verify=${skip_tls} --timeout=30s" &> "${object_collection_path}/backup-${backup}.log" &
23+
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout 30s /velero backup logs ${backup} --insecure-skip-tls-verify=${skip_tls} --timeout=30s" &> "${object_collection_path}/backup-${backup}.log" &
2424

2525
wait

must-gather/collection-scripts/logs/gather_logs_pvb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,5 @@ object_collection_path=$6
1313
node=$(oc get podvolumebackup $pvb --namespace $ns -o jsonpath='{.spec.node}')
1414
mkdir -p ${object_collection_path}
1515
oc describe podvolumebackup ${pvb} --namespace ${ns} &> "${object_collection_path}/pvb-describe-${pvb}.txt" &
16-
for pod in $(oc get pods -o wide --field-selector spec.nodeName=${node} --selector name=restic --no-headers --namespace $ns | awk '{print $1}'); do
17-
echo "[cluster=${cluster}][ns=${ns}][pod=${pod}] Collecting Pod logs..."
18-
oc logs --all-containers --namespace ${ns} ${pod} --since ${logs_since} &> "${object_collection_path}/current.log" &
19-
echo "[cluster=${cluster}][ns=${ns}][pod=${pod}] Collecting previous Pod logs..."
20-
oc logs --previous --all-containers --namespace ${ns} ${pod} --since ${logs_since} &> "${object_collection_path}/previous.log" &
21-
pwait $max_parallelism
22-
done
23-
16+
# logs covered by restic pod logs in gather_logs_pods
2417
wait

must-gather/collection-scripts/logs/gather_logs_pvr

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ max_parallelism=$4
99
pvr=$5
1010
object_collection_path=$6
1111

12-
# Gather PVR describe and logs
12+
# Gather PVR describe
1313
mkdir -p ${object_collection_path}
1414
oc describe podvolumerestores.velero.io ${pvr} --namespace ${ns} &> "${object_collection_path}/pvr-describe-${pvr}.txt"
15-
echo "[cluster=${cluster}][ns=${ns}][pod=${pod}] Collecting Pod logs..."
16-
oc logs --all-containers --namespace ${ns} ${pod} --since ${logs_since} &> "${object_collection_path}/current.log" &
17-
echo "[cluster=${cluster}][ns=${ns}][pod=${pod}] Collecting previous Pod logs..."
18-
oc logs --previous --all-containers --namespace ${ns} ${pod} --since ${logs_since} &> "${object_collection_path}/previous.log" &
19-
15+
# logs covered by restic pod logs in gather_logs_pods
2016
wait

must-gather/collection-scripts/logs/gather_logs_restore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ timeout=$7
1212
skip_tls=$8
1313

1414
# Gather restore describe and logs
15-
mkdir -p "{object_collection_path}"
15+
mkdir -p "${object_collection_path}"
1616
echo "[cluster=${cluster}][ns=${ns}] Gathering 'velero restore describe ${restore}'"
1717
if [ "$timeout" = "0s" ]; then
18-
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero describe restore ${restore} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/restore-describe-${restore}.txt" &
18+
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout 30s /velero describe restore ${restore} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/restore-describe-${restore}.txt" &
1919
else
20-
oc -n ${ns} exec --request-timeout=${timeout} $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero describe restore ${restore} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/restore-describe-${restore}.txt" &
20+
oc -n ${ns} exec --request-timeout=${timeout} $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout ${timeout} /velero describe restore ${restore} --insecure-skip-tls-verify=${skip_tls} --details" &> "${object_collection_path}/restore-describe-${restore}.txt" &
2121
fi
2222
echo "[cluster=${cluster}][ns=${ns}] Gathering 'velero restore logs ${restore}'"
23-
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "/velero restore logs ${restore} --insecure-skip-tls-verify=${skip_tls} --timeout=30s" &> "${object_collection_path}/restore-${restore}.log" &
23+
oc -n ${ns} exec $(oc -n ${ns} get po -l component=velero -o custom-columns=name:.metadata.name --no-headers) -- /bin/bash -c "timeout 30s /velero restore logs ${restore} --insecure-skip-tls-verify=${skip_tls} --timeout=30s" &> "${object_collection_path}/restore-${restore}.log" &
2424

2525
wait

0 commit comments

Comments
 (0)