From 9b639cb47f9a15334f3cac12a4ebeac6449c3a2b Mon Sep 17 00:00:00 2001 From: Apoorva Appadoo Srinivas Date: Sun, 20 Oct 2024 12:36:51 +0200 Subject: [PATCH] fix: exist check --- config/manager/manager.yaml | 2 +- config/samples/ollama_v1_model.yaml | 4 ++-- internal/controller/model_controller.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 1108cb2..9bad3ee 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -63,7 +63,7 @@ spec: args: - --leader-elect - --health-probe-bind-address=:8081 - image: ghcr.io/startupnationlabs/simple-ollama-operator/operator:b8eda45ff032d75a3a19b55591782aa5d758bbb3 + image: ghcr.io/startupnationlabs/simple-ollama-operator/operator:cb75780e3ab2a3933ec48f86baf6eaa83fadb99b name: manager securityContext: allowPrivilegeEscalation: false diff --git a/config/samples/ollama_v1_model.yaml b/config/samples/ollama_v1_model.yaml index aed6b68..5fd45cd 100644 --- a/config/samples/ollama_v1_model.yaml +++ b/config/samples/ollama_v1_model.yaml @@ -4,6 +4,6 @@ metadata: labels: app.kubernetes.io/name: simple-ollama-operator app.kubernetes.io/managed-by: kustomize - name: model-sample + name: lamamode3.2 spec: - modelName: llama3.2:1b + modelName: llama3.2:3b diff --git a/internal/controller/model_controller.go b/internal/controller/model_controller.go index c103388..7cc565a 100644 --- a/internal/controller/model_controller.go +++ b/internal/controller/model_controller.go @@ -90,10 +90,10 @@ func (r *ModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl res, err := ollamaClient.PostApiShowWithResponse(ctx, ollama_client.PostApiShowJSONRequestBody{ Name: &model.Spec.ModelName, }) - if err == nil { + if err == nil && res.Status() == "200" { logger.Info("Model exists", "Model Name", model.Spec.ModelName, "Ollama URL", modelUrl) if res.JSON200 != nil { - logger.Info("Model exists", "Model Name", model.Spec.ModelName, "Ollama URL", modelUrl) + logger.Info("Model exists", "Model Name", res.JSON200.Parameters, "Ollama URL", modelUrl) return ctrl.Result{}, nil } return ctrl.Result{}, err