waits for the pod to be created
(ctx context.Context, kubeClient kubernetes.Interface, name string, namespace string)
| 1373 | |
| 1374 | // waits for the pod to be created |
| 1375 | func 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 | |
| 1394 | func loadPodSpec(podSpecPath string) (*corev1.Pod, error) { |
| 1395 | var pod corev1.Pod |
no test coverage detected