opendatahub-io / opendatahub-operator

Open Data Hub operator to manage ODH component integrations
https://opendatahub.io
Apache License 2.0
60 stars 139 forks source link

Add component reconciliation pipeline framework #1320

Closed lburgazzoli closed 6 days ago

lburgazzoli commented 1 week ago

Description

This PR introduces a new component reconciliation pipeline framework and a set of reusable action that can be composed according to the need of a specific component. This PR is the result of the work related to RHOAIENG-14676

The main entry point is the ComponentReconcilerBuilder:

 NewReconciler creates a ComponentReconciler for the Dashboard API.
func NewReconciler(ctx context.Context, mgr ctrl.Manager) error {
    componentName := computeComponentName()

    _, err := reconciler.ComponentReconcilerFor[*componentsv1.Dashboard](mgr, componentsv1.DashboardInstanceName, &componentsv1.Dashboard{}).
        Owns(&corev1.ConfigMap{}).
        Owns(&corev1.Secret{}).
        Owns(&appsv1.Deployment{}, builder.WithPredicates(resources.NewDeploymentPredicate())).
        Owns(&routev1.Route{}).
        Watches(&extv1.CustomResourceDefinition{}).
        WithAction(initialize).
        WithAction(devFlags).
        WithAction(render.NewAction(
            render.WithCache(true, render.DefaultCachingKeyFn),
            render.WithLabel(labels.ODH.Component(componentName), "true"),
            render.WithLabel(labels.K8SCommon.PartOf, componentName),
        )).
        WithAction(customizeResources).
        WithAction(deploy.NewAction(
            deploy.WithFieldOwner(componentsv1.DashboardInstanceName),
            deploy.WithLabel(labels.ComponentManagedBy, componentsv1.DashboardInstanceName),
        )).
        WithAction(updatestatus.NewAction(
            updatestatus.WithSelectorLabel(labels.ComponentManagedBy, componentsv1.DashboardInstanceName),
        )).
        WithAction(updateStatus).
        Build(ctx)

    if err != nil {
        return fmt.Errorf("could not create the dashboard controller: %w", err)
    }

    return nil
}

Actions currently provided out of the box are provided by the packages in github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/actions:

How Has This Been Tested?

Screenshot or short clip

Merge criteria

VaishnaviHire commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

ykaliuta commented 1 week ago

May be we do not need e2e mandatory for the branch?

lburgazzoli commented 1 week ago

May be we do not need e2e mandatory for the branch?

I'd like to get this one successfully running as in one of the run, the error was quite strange and I'd like to be sure we are not ignoring anything relevant.

Not it seems there are some issues setting up the environment

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 1 week ago

/test opendatahub-operator-e2e

lburgazzoli commented 6 days ago

/test opendatahub-operator-e2e

codecov[bot] commented 6 days ago

Codecov Report

Attention: Patch coverage is 47.19731% with 471 lines in your changes missing coverage. Please review.

Please upload report for BASE (feature-operator-refactor@9a00ff0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/controller/actions/deploy/action_deploy.go 40.64% 105 Missing and 6 partials :warning:
pkg/utils/test/matchers/jq/jq_support.go 25.00% 60 Missing and 6 partials :warning:
pkg/utils/test/matchers/yq/yq_support.go 38.23% 38 Missing and 4 partials :warning:
...r/actions/deploy/action_deploy_merge_deployment.go 51.38% 23 Missing and 12 partials :warning:
pkg/manifests/kustomize/kustomize_render_opts.go 33.96% 35 Missing :warning:
...ntroller/actions/render/action_render_manifests.go 71.11% 23 Missing and 3 partials :warning:
pkg/manifests/kustomize/kustomize_engine.go 50.00% 17 Missing and 8 partials :warning:
pkg/utils/test/matchers/yq/yq_matcher.go 32.14% 14 Missing and 5 partials :warning:
pkg/utils/test/matchers/jq/jq_matcher.go 43.33% 13 Missing and 4 partials :warning:
pkg/plugins/removerplugin.go 51.85% 11 Missing and 2 partials :warning:
... and 10 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## feature-operator-refactor #1320 +/- ## ============================================================ Coverage ? 24.59% ============================================================ Files ? 52 Lines ? 4265 Branches ? 0 ============================================================ Hits ? 1049 Misses ? 3087 Partials ? 129 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

lburgazzoli commented 6 days ago

@zdtsw @VaishnaviHire @ykaliuta e2e are green, I guess we are ok to merge ? @grdryn @zdtsw I'll address some of the finding in a separate PR if you are ok with that

ykaliuta commented 6 days ago

yes for me

VaishnaviHire commented 6 days ago

/lgtm

openshift-ci[bot] commented 6 days ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: VaishnaviHire

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/opendatahub-io/opendatahub-operator/blob/feature-operator-refactor/OWNERS)~~ [VaishnaviHire] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment