The notebook controller writes the last-activity annotation
before culling the Notebook, however, doesn't remove this
annotation before start. This causes the Notebook to be culled
again before is has a chance to start.

Fix:
* calculate correctly the podFound variable and ensure its value
  its true only if the Pod is actually found. This way the culling
  annotation will be removed when there is no Pod.

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>

Signed-off-by: Apostolos Gerakaris <apoger@arrikto.com>
This commit is contained in:
apoger 2022-09-22 17:07:38 +03:00 committed by GitHub
parent 02e2fa4c65
commit b46583df63
1 changed files with 5 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"os"
"reflect"
"strings"
"time"
@ -208,14 +209,14 @@ func (r *NotebookReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
}
foundPod := &corev1.Pod{}
podFound := false
podFound := true
err = r.Get(ctx, types.NamespacedName{Name: ss.Name + "-0", Namespace: ss.Namespace}, foundPod)
if err != nil && apierrs.IsNotFound(err) {
log.Info("Pod not found...")
podFound = false
} else if err != nil {
return ctrl.Result{}, err
}
podFound = true
// Update Notebook CR status
err = updateNotebookStatus(r, instance, foundStateful, foundPod, req)
@ -310,8 +311,8 @@ func createNotebookStatus(r *NotebookReconciler, nb *v1beta1.Notebook,
}
// Update the status based on the Pod's status
if pod == nil {
log.Info("No pod found. Won't update notebook conditions and containerState")
if reflect.DeepEqual(pod.Status, corev1.PodStatus{}) {
log.Info("No pod.Status found. Won't update notebook conditions and containerState")
return status, nil
}