Skip to content

Commit 4484f16

Browse files
mantissahzc3y1huang
authored andcommitted
fix: check if ENV LONGHORN_LOG_PATH is empty
before collecting the Longhorn logs. ref: longhorn/longhorn 11744 Signed-off-by: James Lu <[email protected]>
1 parent 560565c commit 4484f16

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

hack/collector-longhorn

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ function collect_kubelet_log(){
6464
}
6565

6666
collect_longhorn_logs() {
67-
local src_dir
68-
src_dir=$(join_paths "$HOST_PATH" "$LONGHORN_LOG_PATH")
69-
70-
if [ -d "$src_dir" ]; then
71-
cp -r "$src_dir"/* .
67+
if [[ -n $LONGHORN_LOG_PATH ]]; then
68+
local src_dir
69+
src_dir=$(join_paths "$HOST_PATH" "$LONGHORN_LOG_PATH")
70+
71+
if [ -d "$src_dir" ]; then
72+
cp -r "$src_dir"/* .
73+
else
74+
echo "Longhorn log directory not found: $src_dir" >&2
75+
fi
7276
else
73-
echo "Longhorn log directory not found: $src_dir" >&2
77+
echo "LONGHORN_LOG_PATH is not set. Skipping Longhorn log collection." >&2
7478
fi
7579
}
7680

0 commit comments

Comments
 (0)