@@ -60,10 +60,11 @@ type Predictor struct {
6060 inferenceServiceConfig * v1beta1.InferenceServicesConfig
6161 deploymentMode constants.DeploymentModeType
6262 Log logr.Logger
63+ ForceStopRuntime bool
6364}
6465
6566func NewPredictor (client client.Client , clientset kubernetes.Interface , scheme * runtime.Scheme ,
66- inferenceServiceConfig * v1beta1.InferenceServicesConfig , deploymentMode constants.DeploymentModeType ,
67+ inferenceServiceConfig * v1beta1.InferenceServicesConfig , deploymentMode constants.DeploymentModeType , forceStopRuntime bool ,
6768) Component {
6869 return & Predictor {
6970 client : client ,
@@ -72,6 +73,7 @@ func NewPredictor(client client.Client, clientset kubernetes.Interface, scheme *
7273 inferenceServiceConfig : inferenceServiceConfig ,
7374 deploymentMode : deploymentMode ,
7475 Log : ctrl .Log .WithName ("PredictorReconciler" ),
76+ ForceStopRuntime : forceStopRuntime ,
7577 }
7678}
7779
@@ -185,16 +187,16 @@ func (p *Predictor) Reconcile(ctx context.Context, isvc *v1beta1.InferenceServic
185187 } else {
186188 var err error
187189 podLabelKey = constants .RevisionLabel
190+
191+ // forceStopRuntime := false
192+ // if val, exist := isvc.Annotations[constants.StopAnnotationKey]; exist {
193+ // forceStopRuntime = strings.EqualFold(val, "true")
194+ // }
195+
188196 if kstatus , err = p .reconcileKnativeDeployment (ctx , isvc , & objectMeta , & podSpec ); err != nil {
189197 return ctrl.Result {}, err
190198 }
191-
192- forceStopRuntime := "false"
193- if val , exist := isvc .Annotations [constants .StopAnnotationKey ]; exist {
194- forceStopRuntime = val
195- }
196-
197- if strings .EqualFold (forceStopRuntime , "true" ) {
199+ if p .ForceStopRuntime {
198200 // Exit early if we have already set the status to stopped
199201 existing_stopped_condition := isvc .Status .GetCondition (v1beta1 .Stopped )
200202 if existing_stopped_condition != nil && existing_stopped_condition .Status == corev1 .ConditionTrue {
@@ -205,6 +207,17 @@ func (p *Predictor) Reconcile(ctx context.Context, isvc *v1beta1.InferenceServic
205207 p .Log .Info ("Clearing ISVC status" )
206208 isvc .Status = v1beta1.InferenceServiceStatus {}
207209
210+ predictor_ready_condition := & apis.Condition {
211+ Type : v1beta1 .PredictorReady ,
212+ Status : corev1 .ConditionFalse ,
213+ }
214+ isvc .Status .SetCondition (v1beta1 .PredictorReady , predictor_ready_condition )
215+
216+ ingress_ready_condition := & apis.Condition {
217+ Type : v1beta1 .IngressReady ,
218+ Status : corev1 .ConditionFalse ,
219+ }
220+ isvc .Status .SetCondition (v1beta1 .IngressReady , ingress_ready_condition )
208221 // Add the stopped condition
209222 stopped_condition := & apis.Condition {
210223 Type : v1beta1 .Stopped ,
@@ -220,6 +233,7 @@ func (p *Predictor) Reconcile(ctx context.Context, isvc *v1beta1.InferenceServic
220233 }
221234 isvc .Status .SetCondition (v1beta1 .Stopped , resume_condition )
222235 }
236+
223237 }
224238
225239 statusSpec := isvc .Status .Components [v1beta1 .PredictorComponent ]
@@ -619,6 +633,8 @@ func (p *Predictor) reconcileKnativeDeployment(ctx context.Context, isvc *v1beta
619633 if err != nil {
620634 return nil , errors .Wrapf (err , "fails to reconcile predictor" )
621635 }
622- isvc .Status .PropagateStatus (v1beta1 .PredictorComponent , kstatus )
636+ if ! p .ForceStopRuntime {
637+ isvc .Status .PropagateStatus (v1beta1 .PredictorComponent , kstatus )
638+ }
623639 return kstatus , nil
624640}
0 commit comments