Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Feb 12, 2025
1 parent fda6430 commit 27cc5a2
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 63 deletions.
3 changes: 0 additions & 3 deletions controllers/components/codeflare/codeflare_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(checkPreConditions).
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
WithAction(releases.NewAction()).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/gc"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/render/kustomize"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/status/releases"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/status/deployments"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions/status/releases"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/handlers"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/component"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/predicates/resources"
Expand Down Expand Up @@ -42,9 +42,9 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
).
// Add FeastOperator-specific actions
WithAction(deployments.NewAction()).
WithAction(releases.NewAction()).
WithAction(initialize).
WithAction(devFlags).
WithAction(releases.NewAction()).
WithAction(kustomize.NewAction(
kustomize.WithCache(),
kustomize.WithLabel(labels.ODH.Component(ComponentName), labels.True),
Expand Down
6 changes: 1 addition & 5 deletions controllers/components/kserve/kserve_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,9 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(predicates.DefaultPredicate)).

// actions

// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(checkPreConditions).
WithAction(deployments.NewAction()).
WithAction(setStatusFields).
WithAction(checkPreConditions).
WithAction(initialize).
WithAction(devFlags).
WithAction(releases.NewAction()).
Expand Down
6 changes: 1 addition & 5 deletions controllers/components/kueue/kueue_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,8 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(checkPreConditions).
WithAction(deployments.NewAction()).
// Add Kueue-specific actions
WithAction(checkPreConditions). // check if CRD multikueueconfigs/multikueueclusters with v1alpha1 exist in cluster and not in termination
WithAction(initialize).
WithAction(devFlags).
WithAction(releases.NewAction()).
Expand Down
2 changes: 1 addition & 1 deletion controllers/components/kueue/kueue_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func checkPreConditions(ctx context.Context, rr *odhtypes.ReconciliationRequest)
return odherrors.NewStopError("failed to check %s CRDs version: %w", gvk.MultiKueueConfigV1Alpha1, err)
}

if rConfig || rCluster {
if !rConfig || !rCluster {
return odherrors.NewStopError(MultiKueueCRDMessage)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,9 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags). // devFlags triggerd by changes in DSC kserve and ModelMeshServing, also update .status.devflagurl
WithAction(devFlags).
WithAction(kustomize.NewAction(
kustomize.WithCache(),
kustomize.WithLabel(labels.ODH.Component(LegacyComponentName), labels.True),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
},
)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,9 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
// namespaces that may not be known when the controller is started, hence
// it should be watched dynamically
WatchesGVK(gvk.ServiceMeshMember, reconciler.Dynamic()).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(checkPreConditions).
WithAction(deployments.NewAction()).
WithAction(updateStatus).
// past initial status computation
WithAction(checkPreConditions).
WithAction(initialize).
WithAction(releases.NewAction()).
WithAction(configureDependencies).
Expand Down
3 changes: 0 additions & 3 deletions controllers/components/ray/ray_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down
6 changes: 1 addition & 5 deletions controllers/components/trustyai/trustyai_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
},
)),
).
// Add TrustyAI-specific actions
WithAction(checkPreConditions). // check if CRD isvc is there
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(checkPreConditions).
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down
23 changes: 6 additions & 17 deletions controllers/components/trustyai/trustyai_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ import (
"context"
"fmt"

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
Expand All @@ -33,23 +30,15 @@ import (
)

func checkPreConditions(ctx context.Context, rr *odhtypes.ReconciliationRequest) error {
t, ok := rr.Instance.(*componentApi.TrustyAI)
if !ok {
return fmt.Errorf("resource instance %v is not a componentApi.TrustyAI)", rr.Instance)
isvc, err := cluster.HasCRD(ctx, rr.Client, gvk.InferenceServices)
if err != nil {
return odherrors.NewStopError("failed to check %s CRDs version: %w", gvk.InferenceServices, err)
}

if err := cluster.CustomResourceDefinitionExists(ctx, rr.Client, gvk.InferenceServices.GroupKind()); err != nil {
s := t.GetStatus()
s.Phase = status.PhaseNotReady
meta.SetStatusCondition(&s.Conditions, metav1.Condition{
Type: status.ConditionTypeReady,
Status: metav1.ConditionFalse,
Reason: status.ISVCMissingCRDReason,
Message: status.ISVCMissingCRDMessage,
ObservedGeneration: s.ObservedGeneration,
})
return odherrors.NewStopError("failed to find InferenceService CRD: %v", err)
if !isvc {
return odherrors.NewStopError(status.ISVCMissingCRDMessage)
}

return nil
}

Expand Down
3 changes: 0 additions & 3 deletions controllers/components/workbenches/workbenches_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ func (s *componentHandler) NewComponentReconciler(ctx context.Context, mgr ctrl.
reconciler.WithPredicates(
component.ForLabel(labels.ODH.Component(LegacyComponentName), labels.True)),
).
// Detecting component status should be the first step as the
// subsequent action could fail for transient errors, but we
// should report the current component status if possible
WithAction(deployments.NewAction()).
WithAction(initialize).
WithAction(devFlags).
Expand Down

0 comments on commit 27cc5a2

Please sign in to comment.