diff --git a/api/cluster/controller.go b/api/cluster/controller.go index 570b46f18..d2754ac7f 100644 --- a/api/cluster/controller.go +++ b/api/cluster/controller.go @@ -223,10 +223,16 @@ func (c *controller) Deploy(ctx context.Context, modelService *models.Service) ( return nil, errors.Wrapf(err, fmt.Sprintf("%v (%s)", ErrUnableToCreateInferenceService, isvcName)) } - s, err := c.kserveClient.InferenceServices(modelService.Namespace).Create(spec) + s, err := c.kserveClient.InferenceServices(modelService.Namespace).Get(modelService.Name, metav1.GetOptions{}) if err != nil { - log.Errorf("unable to create inference service %s: %v", isvcName, err) - return nil, errors.Wrapf(err, fmt.Sprintf("%v (%s)", ErrUnableToCreateInferenceService, isvcName)) + if !kerrors.IsNotFound(err) { + return nil, errors.Wrapf(err, "unable to check status of inference service: %s", s.Name) + } + s, err = c.kserveClient.InferenceServices(modelService.Namespace).Create(spec) + if err != nil { + log.Errorf("unable to create inference service %s: %v", isvcName, err) + return nil, errors.Wrapf(err, fmt.Sprintf("%v (%s)", ErrUnableToCreateInferenceService, isvcName)) + } } if c.deploymentConfig.PodDisruptionBudget.Enabled { diff --git a/api/cluster/controller_test.go b/api/cluster/controller_test.go index e3f2f0e33..df2792cba 100644 --- a/api/cluster/controller_test.go +++ b/api/cluster/controller_test.go @@ -453,7 +453,10 @@ func TestController_DeployInferenceService(t *testing.T) { nil, errors.New("error creating inference service"), }, - checkResult: nil, + checkResult: &inferenceServiceReactor{ + nil, + kerrors.NewNotFound(schema.GroupResource{}, ""), + }, deployTimeout: deployTimeout, createPdbResult: &pdbReactor{pdb, nil}, createVsResult: &vsReactor{vs, nil}, @@ -468,7 +471,7 @@ func TestController_DeployInferenceService(t *testing.T) { }, checkResult: &inferenceServiceReactor{ nil, - errors.New("error check"), + kerrors.NewNotFound(schema.GroupResource{}, ""), }, deployTimeout: deployTimeout, createPdbResult: &pdbReactor{pdb, nil}, @@ -639,7 +642,6 @@ func TestController_DeployInferenceService(t *testing.T) { kfClient.PrependReactor(createMethod, inferenceServiceResource, func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { return true, tt.createResult.isvc, tt.createResult.err }) - kfClient.PrependReactor(deleteMethod, inferenceServiceResource, func(action ktesting.Action) (handled bool, ret runtime.Object, err error) { return true, nil, nil })