test fix post-mortem not showing (#21328)

pull/21333/head
Medya Ghazizadeh 2025-08-13 11:27:44 -07:00 committed by GitHub
parent 772a9ee395
commit 770d5ce054
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -435,6 +435,7 @@ func VolumeSnapshotWait(ctx context.Context, t *testing.T, profile string, ns st
}
// Status returns a minikube component status as a string
// If the command outputs multiple lines, only the first line is returned to avoid https://github.com/kubernetes/minikube/issues/21326
func Status(ctx context.Context, t *testing.T, path string, profile string, key string, node string) string {
t.Helper()
// Reminder of useful keys: "Host", "Kubelet", "APIServer"
@ -442,7 +443,15 @@ func Status(ctx context.Context, t *testing.T, path string, profile string, key
if err != nil {
t.Logf("status error: %v (may be ok)", err)
}
return strings.TrimSpace(rr.Stdout.String())
out := strings.TrimSpace(rr.Stdout.String())
if out == "" {
return out
}
// Take only the first line if multi-line (ignore warnings or extra notes)
if idx := strings.IndexByte(out, '\n'); idx >= 0 {
out = out[:idx]
}
return strings.TrimSpace(out)
}
// showPodLogs logs debug info for pods