Skip to content

Commit

Permalink
Merge pull request #473 from fosterseth/fix_watch_pod_event_nil
Browse files Browse the repository at this point in the history
k8s createPod panic
  • Loading branch information
jneedle authored Nov 12, 2021
2 parents 9c0145e + bca3e7b commit c70c1ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ func (kw *kubeUnit) createPod(env map[string]string) error {
ctxPodReady, _ = context.WithTimeout(kw.ctx, kw.podPendingTimeout)
}
ev, err := watch2.UntilWithSync(ctxPodReady, lw, &corev1.Pod{}, nil, podRunningAndReady)
if ev == nil || ev.Object == nil {
return fmt.Errorf("did not return an event while watching pod for work unit %s", kw.ID())
}
var ok bool
kw.pod, ok = ev.Object.(*corev1.Pod)
if !ok {
Expand All @@ -234,9 +237,6 @@ func (kw *kubeUnit) createPod(env map[string]string) error {

return err
}
if ev == nil {
return fmt.Errorf("pod disappeared during watch")
}

return nil
}
Expand Down

0 comments on commit c70c1ef

Please sign in to comment.