Skip to content

Commit a87531a

Browse files
committed
test source
Signed-off-by: Jooho Lee <jlee@redhat.com>
1 parent 2c6c038 commit a87531a

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

pkg/apis/serving/v1beta1/inference_service_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const (
124124
LatestDeploymentReady apis.ConditionType = "LatestDeploymentReady"
125125
// Stopped is set when the inference service has been stopped and all related objects are deleted
126126
Stopped apis.ConditionType = "Stopped"
127+
Ready apis.ConditionType = "Ready"
127128
)
128129

129130
type ModelStatus struct {

pkg/controller/v1beta1/inferenceservice/components/predictor.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ type Predictor struct {
6060
inferenceServiceConfig *v1beta1.InferenceServicesConfig
6161
deploymentMode constants.DeploymentModeType
6262
Log logr.Logger
63+
ForceStopRuntime bool
6364
}
6465

6566
func 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
}

pkg/controller/v1beta1/inferenceservice/controller.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,14 @@ func (r *InferenceServiceReconciler) Reconcile(ctx context.Context, req ctrl.Req
220220
return reconcile.Result{}, err
221221
}
222222

223+
forceStopRuntime := false
224+
if val, exist := isvc.Annotations[constants.StopAnnotationKey]; exist {
225+
forceStopRuntime = strings.EqualFold(val, "true")
226+
}
227+
223228
reconcilers := []components.Component{}
224229
if deploymentMode != constants.ModelMeshDeployment {
225-
reconcilers = append(reconcilers, components.NewPredictor(r.Client, r.Clientset, r.Scheme, isvcConfig, deploymentMode))
230+
reconcilers = append(reconcilers, components.NewPredictor(r.Client, r.Clientset, r.Scheme, isvcConfig, deploymentMode, forceStopRuntime))
226231
}
227232
if isvc.Spec.Transformer != nil {
228233
reconcilers = append(reconcilers, components.NewTransformer(r.Client, r.Clientset, r.Scheme, isvcConfig, deploymentMode))
@@ -254,8 +259,10 @@ func (r *InferenceServiceReconciler) Reconcile(ctx context.Context, req ctrl.Req
254259
if isvc.Spec.Explainer != nil {
255260
componentList = append(componentList, v1beta1.ExplainerComponent)
256261
}
257-
isvc.Status.PropagateCrossComponentStatus(componentList, v1beta1.RoutesReady)
258-
isvc.Status.PropagateCrossComponentStatus(componentList, v1beta1.LatestDeploymentReady)
262+
if !forceStopRuntime {
263+
isvc.Status.PropagateCrossComponentStatus(componentList, v1beta1.RoutesReady)
264+
isvc.Status.PropagateCrossComponentStatus(componentList, v1beta1.LatestDeploymentReady)
265+
}
259266
}
260267
// Reconcile ingress
261268
ingressConfig, err := v1beta1.NewIngressConfig(isvcConfigMap)

0 commit comments

Comments
 (0)