Skip to content

Commit d8d5647

Browse files
committed
Check the presence of ps and pkill binaries too
1 parent 4a34714 commit d8d5647

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/cli/admin/mustgather/mustgather.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ usage_percentage=$(df -P "$target_dir" | awk 'NR==2 {print $5}' | sed 's/%%//')
9999
echo "[disk usage checker] Volume usage percentage: current = ${usage_percentage} ; allowed = ${usage_percentage_limit}"
100100
if [ "$usage_percentage" -gt "$usage_percentage_limit" ]; then
101101
echo "[disk usage checker] Disk usage exceeds the volume percentage of ${usage_percentage_limit} for mounted directory, terminating..."
102-
if command -v setsid >/dev/null 2>&1; then
102+
if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then
103103
ps -o sess --no-headers | sort -u | while read sid; do
104104
[[ "$sid" -eq "${$}" ]] && continue
105105
pkill --signal SIGKILL --session "$sid"
@@ -1329,9 +1329,9 @@ func buildPodCommand(
13291329
cmd.WriteString(volumeCheckerScript)
13301330
cmd.WriteString(` & `)
13311331

1332-
// Start the gather command in a separate session if setsid is available.
1333-
// Fall back to simpler approach if setsid is not present (minimal images).
1334-
cmd.WriteString("if command -v setsid >/dev/null 2>&1; then\n")
1332+
// Start the gather command in a separate session if setsid, ps, and pkill are available.
1333+
// Fall back to simpler approach if any of these tools are not present (minimal images).
1334+
cmd.WriteString("if command -v setsid >/dev/null 2>&1 && command -v ps >/dev/null 2>&1 && command -v pkill >/dev/null 2>&1; then\n")
13351335
cmd.WriteString(" setsid -w bash <<-MUSTGATHER_EOF\n")
13361336
cmd.WriteString(gatherCommand)
13371337
cmd.WriteString("\nMUSTGATHER_EOF\n")

0 commit comments

Comments
 (0)