From 84ba988b84eeee59de38a7f8ea23a3e89ae1adb9 Mon Sep 17 00:00:00 2001 From: mtrujillo Date: Mon, 2 Dec 2024 08:54:26 -0500 Subject: [PATCH] Add NIM flag logic Signed-off-by: mtrujillo --- config/base/params.env | 2 +- config/manager/manager.yaml | 6 ++++++ main.go | 19 ++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/config/base/params.env b/config/base/params.env index b47e089a..461891f0 100644 --- a/config/base/params.env +++ b/config/base/params.env @@ -4,4 +4,4 @@ caikit-standalone-image=quay.io/opendatahub/caikit-nlp:fast tgis-image=quay.io/opendatahub/text-generation-inference:fast ovms-image=quay.io/opendatahub/openvino_model_server:2024.3-release vllm-image=quay.io/opendatahub/vllm:fast - +nim-state=removed diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 7169befb..bb156abb 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -71,6 +71,12 @@ spec: name: service-mesh-refs key: MESH_NAMESPACE optional: true + - name: NIM_STATE + valueFrom: + configMapKeyRef: + name: odh-model-controller-parameters + key: nim-state + optional: true livenessProbe: httpGet: path: /healthz diff --git a/main.go b/main.go index 4ac99d57..5bff7899 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "context" "flag" "os" + "slices" "strconv" corev1 "k8s.io/api/core/v1" @@ -242,13 +243,17 @@ func main() { } ctx := ctrl.SetupSignalHandler() - if err = (&controllers.NimAccountReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("NimAccountReconciler"), - KClient: kclient, - }).SetupWithManager(mgr, ctx); err != nil { - setupLog.Error(err, "unable to create controller NIM Account controller") - os.Exit(1) + nimState := os.Getenv("NIM_STATE") + + if !slices.Contains([]string{"removed", ""}, nimState) { + if err = (&controllers.NimAccountReconciler{ + Client: mgr.GetClient(), + Log: ctrl.Log.WithName("controllers").WithName("NimAccountReconciler"), + KClient: kclient, + }).SetupWithManager(mgr, ctx); err != nil { + setupLog.Error(err, "unable to create controller NIM Account controller") + os.Exit(1) + } } if err = builder.WebhookManagedBy(mgr).