Skip to content

Commit ddcaab1

Browse files
fix: support serverless logs and robust timeout in diagnose scripts
Signed-off-by: Ayush-Patel-56 <ayushpatel2731@gmail.com>
1 parent a51c9e1 commit ddcaab1

4 files changed

Lines changed: 121 additions & 5 deletions

File tree

tools/diagnose-fluid-alluxio.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ print_usage() {
2121
run() {
2222
echo
2323
echo "-----------------run $*------------------"
24-
timeout 10s "$@"
24+
if command -v timeout >/dev/null 2>&1; then
25+
timeout 10s "$@"
26+
elif command -v gtimeout >/dev/null 2>&1; then
27+
gtimeout 10s "$@"
28+
elif command -v perl >/dev/null 2>&1; then
29+
# Use Perl to enforce timeout on systems without GNU coreutils (like standard macOS)
30+
perl -e 'alarm shift; exec @ARGV' 10 "$@"
31+
else
32+
"$@"
33+
fi
2534
if [ $? != 0 ]; then
2635
echo "failed to collect info: $*"
2736
fi
@@ -57,6 +66,25 @@ runtime_pod_logs() {
5766
core_component "${runtime_namespace}" "alluxio-fuse" "role=alluxio-fuse" "release=${runtime_name}"
5867
}
5968

69+
serverless_pod_logs() {
70+
local namespace="${runtime_namespace}"
71+
local label_selector="serverless.fluid.io/inject=true"
72+
73+
# Get all pods with the serverless inject label
74+
local pods=$(kubectl get po -n ${namespace} -l ${label_selector} -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
75+
76+
if [ -n "$pods" ]; then
77+
mkdir -p "$diagnose_dir/pods-${namespace}-serverless"
78+
for po in ${pods}; do
79+
# Find all containers containing fluid-fuse (covers init-fluid-fuse and fluid-fuse)
80+
local containers=$(kubectl get po ${po} -n ${namespace} -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}' | tr ' ' '\n' | grep 'fluid-fuse')
81+
for container in ${containers}; do
82+
kubectl logs "${po}" -c "${container}" -n ${namespace} &>"$diagnose_dir/pods-${namespace}-serverless/${po}-${container}.log" 2>&1
83+
done
84+
done
85+
fi
86+
}
87+
6088
core_component() {
6189
# namespace container selectors...
6290
local namespace="$1"
@@ -105,6 +133,7 @@ pd_collect() {
105133
pod_status "${fluid_namespace}"
106134
pod_status "${runtime_namespace}"
107135
runtime_pod_logs
136+
serverless_pod_logs
108137
fluid_pod_logs
109138
kubectl_resource
110139
archive

tools/diagnose-fluid-goosefs.sh

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ print_usage() {
1919
run() {
2020
echo
2121
echo "-----------------run $*------------------"
22-
timeout 10s "$@"
22+
if command -v timeout >/dev/null 2>&1; then
23+
timeout 10s "$@"
24+
elif command -v gtimeout >/dev/null 2>&1; then
25+
gtimeout 10s "$@"
26+
elif command -v perl >/dev/null 2>&1; then
27+
# Use Perl to enforce timeout on systems without GNU coreutils (like standard macOS)
28+
perl -e 'alarm shift; exec @ARGV' 10 "$@"
29+
else
30+
"$@"
31+
fi
2332
if [ $? != 0 ]; then
2433
echo "failed to collect info: $*"
2534
fi
@@ -50,6 +59,25 @@ runtime_pod_logs() {
5059
core_component "${runtime_namespace}" "goosefs-fuse" "role=goosefs-fuse" "release=${runtime_name}"
5160
}
5261

62+
serverless_pod_logs() {
63+
local namespace="${runtime_namespace}"
64+
local label_selector="serverless.fluid.io/inject=true"
65+
66+
# Get all pods with the serverless inject label
67+
local pods=$(kubectl get po -n ${namespace} -l ${label_selector} -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
68+
69+
if [ -n "$pods" ]; then
70+
mkdir -p "$diagnose_dir/pods-${namespace}-serverless"
71+
for po in ${pods}; do
72+
# Find all containers containing fluid-fuse (covers init-fluid-fuse and fluid-fuse)
73+
local containers=$(kubectl get po ${po} -n ${namespace} -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}' | tr ' ' '\n' | grep 'fluid-fuse')
74+
for container in ${containers}; do
75+
kubectl logs "${po}" -c "${container}" -n ${namespace} &>"$diagnose_dir/pods-${namespace}-serverless/${po}-${container}.log" 2>&1
76+
done
77+
done
78+
fi
79+
}
80+
5381
core_component() {
5482
# namespace container selectors...
5583
local namespace="$1"
@@ -65,7 +93,7 @@ core_component() {
6593
mkdir -p "$diagnose_dir/pods-${namespace}"
6694
pods=$(kubectl get po -n ${namespace} "${constrains}" | awk '{print $1}' | grep -v NAME)
6795
for po in ${pods}; do
68-
if [[ "${namespace}"="${fluid_namesapce}" ]]; then
96+
if [[ "${namespace}" == "${fluid_namespace}" ]]; then
6997
kubectl logs "${po}" -c "$container" -n ${namespace} &>"$diagnose_dir/pods-${namespace}/${po}-${container}.log" 2>&1
7098
else
7199
kubectl cp "${namespace}/${po}":/opt/goosefs/logs -c "${container}" "$diagnose_dir/pods-${namespace}/${po}-${container}" 2>&1
@@ -93,6 +121,7 @@ pd_collect() {
93121
pod_status "${fluid_namespace}"
94122
pod_status "${runtime_namespace}"
95123
runtime_pod_logs
124+
serverless_pod_logs
96125
fluid_pod_logs
97126
kubectl_resource
98127
archive

tools/diagnose-fluid-jindo.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ print_usage() {
2121
run() {
2222
echo
2323
echo "-----------------run $*------------------"
24-
timeout 10s "$@"
24+
if command -v timeout >/dev/null 2>&1; then
25+
timeout 10s "$@"
26+
elif command -v gtimeout >/dev/null 2>&1; then
27+
gtimeout 10s "$@"
28+
elif command -v perl >/dev/null 2>&1; then
29+
# Use Perl to enforce timeout on systems without GNU coreutils (like standard macOS)
30+
perl -e 'alarm shift; exec @ARGV' 10 "$@"
31+
else
32+
"$@"
33+
fi
2534
if [ $? != 0 ]; then
2635
echo "failed to collect info: $*"
2736
fi
@@ -55,6 +64,25 @@ runtime_pod_logs() {
5564
core_component "${runtime_namespace}" "jindofs-fuse" "role=jindofs-fuse" "release=${runtime_name}"
5665
}
5766

67+
serverless_pod_logs() {
68+
local namespace="${runtime_namespace}"
69+
local label_selector="serverless.fluid.io/inject=true"
70+
71+
# Get all pods with the serverless inject label
72+
local pods=$(kubectl get po -n ${namespace} -l ${label_selector} -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
73+
74+
if [ -n "$pods" ]; then
75+
mkdir -p "$diagnose_dir/pods-${namespace}-serverless"
76+
for po in ${pods}; do
77+
# Find all containers containing fluid-fuse (covers init-fluid-fuse and fluid-fuse)
78+
local containers=$(kubectl get po ${po} -n ${namespace} -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}' | tr ' ' '\n' | grep 'fluid-fuse')
79+
for container in ${containers}; do
80+
kubectl logs "${po}" -c "${container}" -n ${namespace} &>"$diagnose_dir/pods-${namespace}-serverless/${po}-${container}.log" 2>&1
81+
done
82+
done
83+
fi
84+
}
85+
5886
core_component() {
5987
# namespace container selectors...
6088
local namespace="$1"
@@ -99,6 +127,7 @@ pd_collect() {
99127
pod_status "${fluid_namespace}"
100128
pod_status "${runtime_namespace}"
101129
runtime_pod_logs
130+
serverless_pod_logs
102131
fluid_pod_logs
103132
kubectl_resource
104133
archive

tools/diagnose-fluid-juicefs.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ print_usage() {
2121
run() {
2222
echo
2323
echo "-----------------run $*------------------"
24-
timeout 10s "$@"
24+
if command -v timeout >/dev/null 2>&1; then
25+
timeout 10s "$@"
26+
elif command -v gtimeout >/dev/null 2>&1; then
27+
gtimeout 10s "$@"
28+
elif command -v perl >/dev/null 2>&1; then
29+
# Use Perl to enforce timeout on systems without GNU coreutils (like standard macOS)
30+
perl -e 'alarm shift; exec @ARGV' 10 "$@"
31+
else
32+
"$@"
33+
fi
2534
if [ $? != 0 ]; then
2635
echo "failed to collect info: $*"
2736
fi
@@ -54,6 +63,25 @@ runtime_pod_logs() {
5463
core_component "${runtime_namespace}" "juicefs-fuse" "role=juicefs-fuse" "release=${runtime_name}"
5564
}
5665

66+
serverless_pod_logs() {
67+
local namespace="${runtime_namespace}"
68+
local label_selector="serverless.fluid.io/inject=true"
69+
70+
# Get all pods with the serverless inject label
71+
local pods=$(kubectl get po -n ${namespace} -l ${label_selector} -o jsonpath='{.items[*].metadata.name}' 2>/dev/null)
72+
73+
if [ -n "$pods" ]; then
74+
mkdir -p "$diagnose_dir/pods-${namespace}-serverless"
75+
for po in ${pods}; do
76+
# Find all containers containing fluid-fuse (covers init-fluid-fuse and fluid-fuse)
77+
local containers=$(kubectl get po ${po} -n ${namespace} -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}' | tr ' ' '\n' | grep 'fluid-fuse')
78+
for container in ${containers}; do
79+
kubectl logs "${po}" -c "${container}" -n ${namespace} &>"$diagnose_dir/pods-${namespace}-serverless/${po}-${container}.log" 2>&1
80+
done
81+
done
82+
fi
83+
}
84+
5785
core_component() {
5886
# namespace container selectors...
5987
local namespace="$1"
@@ -98,6 +126,7 @@ pd_collect() {
98126
pod_status "${fluid_namespace}"
99127
pod_status "${runtime_namespace}"
100128
runtime_pod_logs
129+
serverless_pod_logs
101130
fluid_pod_logs
102131
kubectl_resource
103132
archive

0 commit comments

Comments
 (0)