Skip to content

Commit 035a289

Browse files
committed
fix: restart devpod
1 parent 072fe79 commit 035a289

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

pkg/devspace/devpod/devpod.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ func (d *devPod) startWithRetry(ctx *devspacecontext.Context, devPodConfig *late
141141

142142
// check if we need to restart
143143
if selectedPod != nil {
144-
shouldTerminate := false
144+
shouldRestart := false
145145
err := wait.PollImmediateUntil(time.Second, func() (bool, error) {
146146
pod, err := ctx.KubeClient.KubeClient().CoreV1().Pods(selectedPod.Pod.Namespace).Get(ctx.Context, selectedPod.Pod.Name, metav1.GetOptions{})
147147
if err != nil {
148148
if kerrors.IsNotFound(err) {
149149
ctx.Log.Debugf("Restart dev %s because pod isn't found anymore", devPodConfig.Name)
150-
d.restart(ctx, devPodConfig, options)
150+
shouldRestart = true
151151
return true, nil
152152
}
153153

@@ -156,17 +156,16 @@ func (d *devPod) startWithRetry(ctx *devspacecontext.Context, devPodConfig *late
156156
return false, nil
157157
} else if pod.DeletionTimestamp != nil {
158158
ctx.Log.Debugf("Restart dev %s because pod is terminating", devPodConfig.Name)
159-
d.restart(ctx, devPodConfig, options)
159+
shouldRestart = true
160160
return true, nil
161161
}
162162

163-
shouldTerminate = true
164163
return true, nil
165164
}, ctx.Context.Done())
166-
if err != nil && err != context.Canceled {
165+
if err != nil {
167166
ctx.Log.Errorf("error restarting dev: %v", err)
168-
}
169-
if !shouldTerminate {
167+
} else if shouldRestart {
168+
d.restart(ctx, devPodConfig, options)
170169
return
171170
}
172171
}

0 commit comments

Comments
 (0)