Skip to content

Commit

Permalink
fix(kserve): check on multiple depends operators if all pre-installed (
Browse files Browse the repository at this point in the history
…opendatahub-io#744) (opendatahub-io#119)

Signed-off-by: Wen Zhou <[email protected]>
(cherry picked from commit 57c4b82)
  • Loading branch information
zdtsw authored and VaishnaviHire committed Dec 11, 2023
1 parent afefecb commit e77e993
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ func (k *Kserve) ReconcileComponent(cli client.Client, owner metav1.Object, dsci
}

// check on dependent operators if all installed in cluster
// dependent operators set in checkRequiredOperatorsInstalled()
if err := checkRequiredOperatorsInstalled(cli); err != nil {
return err
dependOpsErrors := checkDepedentOps(cli).ErrorOrNil()
if dependOpsErrors != nil {
return dependOpsErrors
}

if err := k.configureServerless(dscispec); err != nil {
Expand Down Expand Up @@ -188,21 +188,23 @@ func (k *Kserve) removeServerlessFeatures(instance *dsciv1.DSCInitializationSpec
return nil
}

func checkRequiredOperatorsInstalled(cli client.Client) error {
func checkDepedentOps(cli client.Client) *multierror.Error {
var multiErr *multierror.Error

checkAndAppendError := func(operatorName string) {
if found, err := deploy.OperatorExists(cli, operatorName); err != nil {
multiErr = multierror.Append(multiErr, err)
} else if !found {
err = fmt.Errorf("operator %s not found. Please install the operator before enabling %s component",
operatorName, ComponentName)
multiErr = multierror.Append(multiErr, err)
}
if found, err := deploy.OperatorExists(cli, ServiceMeshOperator); err != nil {
multiErr = multierror.Append(multiErr, err)
} else if !found {
err = fmt.Errorf("operator %s not found. Please install the operator before enabling %s component",
ServiceMeshOperator, ComponentName)
multiErr = multierror.Append(multiErr, err)
}

checkAndAppendError(ServiceMeshOperator)
checkAndAppendError(ServerlessOperator)

return multiErr.ErrorOrNil()
if found, err := deploy.OperatorExists(cli, ServerlessOperator); err != nil {
multiErr = multierror.Append(multiErr, err)
} else if !found {
err = fmt.Errorf("operator %s not found. Please install the operator before enabling %s component",
ServerlessOperator, ComponentName)
multiErr = multierror.Append(multiErr, err)
}
return multiErr
}

0 comments on commit e77e993

Please sign in to comment.