@@ -30,7 +30,6 @@ import (
3030 "sigs.k8s.io/controller-runtime/pkg/log"
3131 "sigs.k8s.io/controller-runtime/pkg/reconcile"
3232
33- "github.com/seldonio/seldon-core/operator/v2/apis/mlops/v1alpha1"
3433 mlopsv1alpha1 "github.com/seldonio/seldon-core/operator/v2/apis/mlops/v1alpha1"
3534 "github.com/seldonio/seldon-core/operator/v2/controllers/reconcilers/common"
3635 serverreconcile "github.com/seldonio/seldon-core/operator/v2/controllers/reconcilers/server"
@@ -106,12 +105,6 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
106105 return reconcile.Result {}, reconcile .TerminalError (err )
107106 }
108107
109- if err := r .Scheduler .ServerNotify (ctx , nil , []v1alpha1.Server {* server }, false ); err != nil {
110- logger .Error (err , "Failed calling ServerNotify" , "name" , req .Name , "namespace" , req .Namespace , "spec" , server .Spec )
111- r .updateStatusFromError (ctx , logger , server , err )
112- return reconcile.Result {}, err
113- }
114-
115108 server .Spec .Replicas = ptr .To (int32 (scalingSpec .Replicas ))
116109
117110 var sr common.Reconciler
@@ -142,13 +135,23 @@ func (r *ServerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
142135 return reconcile.Result {}, err
143136 }
144137
138+ // attempt to deploy
145139 err = sr .Reconcile ()
146140 if err != nil {
147141 logger .Error (err , "Failed reconciling" , "name" , req .Name , "namespace" , req .Namespace , "spec" , server .Spec )
148142 r .updateStatusFromError (ctx , logger , server , err )
149143 return reconcile.Result {}, err
150144 }
151145
146+ // only after successful deployment of the pods, we notify the scheduler of the number of Servers it can expect that
147+ // will try and connect. It's important we do this after we deploy, otherwise if deployment fails, the scheduler
148+ // may expect the wrong number, and end up waiting for the 10-minute timeout until loading models onto the Servers.
149+ if err := r .Scheduler .ServerNotify (ctx , nil , []mlopsv1alpha1.Server {* server }, false ); err != nil {
150+ logger .Error (err , "Failed calling ServerNotify" , "name" , req .Name , "namespace" , req .Namespace , "spec" , server .Spec )
151+ r .updateStatusFromError (ctx , logger , server , err )
152+ return reconcile.Result {}, err
153+ }
154+
152155 conditions := sr .GetConditions ()
153156 for _ , condition := range conditions {
154157 server .Status .SetCondition (condition )
0 commit comments