Skip to content

Commit

Permalink
update: add a workaround for 2 serving CRDs
Browse files Browse the repository at this point in the history
- both kserve and mdoelmesh ship these 2 CRDs

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Dec 3, 2024
1 parent b6958de commit 18e148e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apis/components/v1/modelcontroller_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ type ModelControllerSpec struct {

// a mini version of the DSCKserve only keep devflags and management spec
type ModelControllerKerveSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

// a mini version of the DSCModelMeshServing only keep devflags and management spec
type ModelControllerMMSpec struct {
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
ManagementState operatorv1.ManagementState `json:"managementState,omitempty"`
common.DevFlagsSpec `json:",inline"`
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/components/kserve/kserve_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/security"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/updatestatus"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/clusterrole"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/crd"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/hash"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/resources"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/reconciler"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
// for to objects that have the label components.opendatahub.io/managed-by
// set to the current owner
//
Watches(&extv1.CustomResourceDefinition{}).
Watches(&extv1.CustomResourceDefinition{}, reconciler.WithPredicates(crd.ServingCRD())).

// operands - dynamically watched
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/security"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/updatestatus"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/clusterrole"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/crd"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/resources"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/reconciler"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
Owns(&rbacv1.RoleBinding{}).
Owns(&rbacv1.ClusterRoleBinding{}).
Owns(&appsv1.Deployment{}, reconciler.WithPredicates(resources.NewDeploymentPredicate())).
Watches(&extv1.CustomResourceDefinition{}). // call ForLabel() + new predicates
Watches(&extv1.CustomResourceDefinition{}, reconciler.WithPredicates(crd.ServingCRD())). // call ForLabel() + new predicates
// Add ModelMeshServing specific actions
WithAction(initialize).
WithAction(devFlags).
Expand Down
14 changes: 14 additions & 0 deletions pkg/controller/predicates/crd/crd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package crd

import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

func ServingCRD() predicate.Predicate {
return predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
return e.ObjectNew.GetName() != "inferenceservices.serving.kserve.io" && e.ObjectNew.GetName() != "servingruntimes.serving.kserve.io"
},
}
}

0 comments on commit 18e148e

Please sign in to comment.