Skip to content

Commit 2023968

Browse files
committed
Tests: only collect logs and IPs from active pods
Multinode tests may end up with a few pods that fail to schedule. These don't have container logs, which causes the logs collection to fail. Similarly, we end up with empty IP addresses if we collect HostIPs from such pods. Just ignore them. Signed-off-by: Dmitry Tantsur <dtantsur@protonmail.com>
1 parent 552c46b commit 2023968

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/suite_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ func getCurrentIronicIPs(ctx context.Context, namespace, name string) []string {
394394
addresses := make([]string, 0, len(pods.Items))
395395
for _, pod := range pods.Items {
396396
// Only use one address per pod, no need for both IP families
397-
addresses = append(addresses, pod.Status.HostIP)
397+
if pod.Status.Phase == corev1.PodRunning {
398+
addresses = append(addresses, pod.Status.HostIP)
399+
}
398400
}
399401
return addresses
400402
}
@@ -588,7 +590,10 @@ func CollectLogs(namespace string) {
588590

589591
writeYAML(&pod, namespace, pod.Name, "pod")
590592

591-
for _, cont := range pod.Spec.Containers {
593+
for _, cont := range pod.Status.ContainerStatuses {
594+
writeContainerLogs(&pod, cont.Name, logDir)
595+
}
596+
for _, cont := range pod.Status.InitContainerStatuses {
592597
writeContainerLogs(&pod, cont.Name, logDir)
593598
}
594599
}

0 commit comments

Comments
 (0)