Skip to content

Commit

Permalink
chore(cleanup): remove checkDependentOperators as duplicated logic (o…
Browse files Browse the repository at this point in the history
…pendatahub-io#996)

- both depedent operators have been check in configureServerlessFeatures

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw authored May 2, 2024
1 parent d749ef8 commit 55320b6
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions components/kserve/kserve_config_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import (
"encoding/json"
"fmt"

"github.com/hashicorp/go-multierror"
operatorv1 "github.com/openshift/api/operator/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels"
)
Expand Down Expand Up @@ -116,7 +114,7 @@ func (k *Kserve) setDefaultDeploymentMode(ctx context.Context, cli client.Client
return nil
}

func (k *Kserve) configureServerless(cli client.Client, instance *dsciv1.DSCInitializationSpec) error {
func (k *Kserve) configureServerless(_ client.Client, instance *dsciv1.DSCInitializationSpec) error {
switch k.Serving.ManagementState {
case operatorv1.Unmanaged: // Bring your own CR
fmt.Println("Serverless CR is not configured by the operator, we won't do anything")
Expand All @@ -133,12 +131,6 @@ func (k *Kserve) configureServerless(cli client.Client, instance *dsciv1.DSCInit
return fmt.Errorf("ServiceMesh is need to set to 'Managed' in DSCI CR, it is required by KServe serving field")
}

// check on dependent operators if all installed in cluster
dependOpsErrors := checkDependentOperators(cli).ErrorOrNil()
if dependOpsErrors != nil {
return dependOpsErrors
}

serverlessFeatures := feature.ComponentFeaturesHandler(k.GetComponentName(), instance, k.configureServerlessFeatures())

if err := serverlessFeatures.Apply(); err != nil {
Expand All @@ -153,24 +145,3 @@ func (k *Kserve) removeServerlessFeatures(instance *dsciv1.DSCInitializationSpec

return serverlessFeatures.Delete()
}

func checkDependentOperators(cli client.Client) *multierror.Error {
var multiErr *multierror.Error

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)
}

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 55320b6

Please sign in to comment.