Skip to content

[ws-manager] Add missing check to fix OOM error #8372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions components/ws-manager/pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,41 @@ func (m *Manager) StartWorkspace(ctx context.Context, req *api.StartWorkspaceReq
retryErr = err

var tempPod corev1.Pod
getErr := m.Clientset.Get(ctx, types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}, &tempPod)
if getErr != nil {
clog.WithError(getErr).WithField("pod.Namespace", pod.Namespace).WithField("pod.Name", pod.Name).Error("was unable to get pod")
// pod doesn't exist, so we are safe to proceed with retry
return false, nil
finalizerRemoved := false
// We do below in loop as sometimes the pod might be already deleted or modified when we attempt to remove the finalizer
// so we first get the pod and then attempt to remove the finalizer
// in case the pod is not found in the first place, we return success
for i := 0; i < 3 && !finalizerRemoved; i++ {
getErr := m.Clientset.Get(ctx, types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}, &tempPod)
if getErr != nil {
if k8serr.IsNotFound(getErr) {
// pod doesn't exist, so we are safe to proceed with retry
return false, nil
}
clog.WithError(getErr).WithField("pod.Namespace", pod.Namespace).WithField("pod.Name", pod.Name).Error("was unable to get pod")
// pod get call failed so we error out
return false, retryErr
}
// we successfully got the pod, now we attempt to remove finalizer
tempPod.Finalizers = []string{}
updateErr := m.Clientset.Update(ctx, &tempPod)
if updateErr != nil {
if k8serr.IsNotFound(updateErr) {
// pod doesn't exist, so we are safe to proceed with retry
return false, nil
}
clog.WithError(updateErr).WithField("pod.Namespace", pod.Namespace).WithField("pod.Name", pod.Name).Error("was unable to remove finalizer")
continue
}
finalizerRemoved = true
}
tempPod.Finalizers = []string{}
updateErr := m.Clientset.Update(ctx, &tempPod)
if updateErr != nil {
clog.WithError(updateErr).WithField("pod.Namespace", pod.Namespace).WithField("pod.Name", pod.Name).Error("was unable to remove finalizer")
// failed to remove finalizer, we not going to be able to create a new pod, so bail out with retry error
// if even after retries we could not remove finalizers, then error out
if !finalizerRemoved {
return false, retryErr
}

deleteErr := m.Clientset.Delete(ctx, &tempPod)
if deleteErr != nil {
if deleteErr != nil && !k8serr.IsNotFound(deleteErr) {
clog.WithError(deleteErr).WithField("pod.Namespace", pod.Namespace).WithField("pod.Name", pod.Name).Error("was unable to delete pod")
// failed to delete pod, so not going to be able to create a new pod, so bail out
return false, retryErr
Expand Down