MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / waitForPod

Function waitForPod

cmd/nvidia-validator/main.go:1375–1392  ·  view source on GitHub ↗

waits for the pod to be created

(ctx context.Context, kubeClient kubernetes.Interface, name string, namespace string)

Source from the content-addressed store, hash-verified

1373
1374// waits for the pod to be created
1375func waitForPod(ctx context.Context, kubeClient kubernetes.Interface, name string, namespace string) error {
1376 for i := 0; i < podCreationWaitRetries; i++ {
1377 // check for the existence of the resource
1378 pod, err := kubeClient.CoreV1().Pods(namespace).Get(ctx, name, meta_v1.GetOptions{})
1379 if err != nil {
1380 return fmt.Errorf("failed to get pod %s, err %w", name, err)
1381 }
1382 if pod.Status.Phase != "Succeeded" {
1383 log.Infof("pod %s is curently in %s phase", name, pod.Status.Phase)
1384 time.Sleep(podCreationSleepIntervalSeconds * time.Second)
1385 continue
1386 }
1387 log.Infof("pod %s have run successfully", name)
1388 // successfully running
1389 return nil
1390 }
1391 return fmt.Errorf("gave up waiting for pod %s to be available", name)
1392}
1393
1394func loadPodSpec(podSpecPath string) (*corev1.Pod, error) {
1395 var pod corev1.Pod

Callers 2

runWorkloadMethod · 0.85
runWorkloadMethod · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected