From 57b6621edbcd2c4d9dc9dd462d6580c2039ca4ac Mon Sep 17 00:00:00 2001 From: YouXam Date: Sat, 13 Jul 2024 23:16:03 +0800 Subject: [PATCH] fix: add default value for replicas Signed-off-by: YouXam --- internal/controller/aimodel_controller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/controller/aimodel_controller.go b/internal/controller/aimodel_controller.go index cf3afc7..e2bca6b 100644 --- a/internal/controller/aimodel_controller.go +++ b/internal/controller/aimodel_controller.go @@ -99,6 +99,11 @@ func (r *AIModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct return ctrl.Result{}, err } + if aimodel.Spec.Replicas == nil { + aimodel.Spec.Replicas = new(int32) + *aimodel.Spec.Replicas = 1 + } + // Define the desired Deployment object dep := r.deploymentForAIModel(aimodel) @@ -144,7 +149,7 @@ func (r *AIModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct } } - // Check if ServiceAccount was updated after last recorded update + // Check if ServiceAccount was updated after the last recorded update lastUpdate, _ := time.Parse(time.RFC3339, found.Spec.Template.ObjectMeta.Annotations["last-serviceaccount-update"]) needsRestart := sa.CreationTimestamp.After(lastUpdate)