mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Fix CheckPodsCondition to print out the correct podName
This commit is contained in:
parent
3ff99a8381
commit
03d08623e8
@ -3918,21 +3918,24 @@ func CheckPodsRunningReadyOrSucceeded(c clientset.Interface, ns string, podNames
|
|||||||
func CheckPodsCondition(c clientset.Interface, ns string, podNames []string, timeout time.Duration, condition podCondition, desc string) bool {
|
func CheckPodsCondition(c clientset.Interface, ns string, podNames []string, timeout time.Duration, condition podCondition, desc string) bool {
|
||||||
np := len(podNames)
|
np := len(podNames)
|
||||||
Logf("Waiting up to %v for %d pods to be %s: %s", timeout, np, desc, podNames)
|
Logf("Waiting up to %v for %d pods to be %s: %s", timeout, np, desc, podNames)
|
||||||
result := make(chan bool, len(podNames))
|
type waitPodResult struct {
|
||||||
|
success bool
|
||||||
|
podName string
|
||||||
|
}
|
||||||
|
result := make(chan waitPodResult, len(podNames))
|
||||||
for _, podName := range podNames {
|
for _, podName := range podNames {
|
||||||
// Launch off pod readiness checkers.
|
// Launch off pod readiness checkers.
|
||||||
go func(name string) {
|
go func(name string) {
|
||||||
err := WaitForPodCondition(c, ns, name, desc, timeout, condition)
|
err := WaitForPodCondition(c, ns, name, desc, timeout, condition)
|
||||||
result <- err == nil
|
result <- waitPodResult{err == nil, name}
|
||||||
}(podName)
|
}(podName)
|
||||||
}
|
}
|
||||||
// Wait for them all to finish.
|
// Wait for them all to finish.
|
||||||
success := true
|
success := true
|
||||||
// TODO(a-robinson): Change to `for range` syntax and remove logging once we
|
for range podNames {
|
||||||
// support only Go >= 1.4.
|
res := <-result
|
||||||
for _, podName := range podNames {
|
if !res.success {
|
||||||
if !<-result {
|
Logf("Pod %[1]s failed to be %[2]s.", res.podName, desc)
|
||||||
Logf("Pod %[1]s failed to be %[2]s.", podName, desc)
|
|
||||||
success = false
|
success = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user