opendatahub-io / opendatahub-operator

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

Implement template rendering action #1364

Closed lburgazzoli closed 2 weeks ago

lburgazzoli commented 2 weeks ago

Description

This PR introduces a new rendering engine that is based on the go text/template package.

The template is rendered to the actual objects taking a subset of the ReconciliationRequest struct: Instance and DSCI so as an example, the ServiceMeshMember template that is part of the model registry component would looks like:

apiVersion: maistra.io/v1
kind: ServiceMeshMember
metadata:
  name: default
  namespace: {{.Instance.Spec.RegistriesNamespace}}
spec:
  controlPlaneRef:
    namespace: {{ .DSCI.Spec.ServiceMesh.ControlPlane.Namespace }}
    name: {{ .DSCI.Spec.ServiceMesh.ControlPlane.Name }}

https://issues.redhat.com/browse/RHOAIENG-15534

How Has This Been Tested?

  1. Enable the model registry component in DSC
  2. Check for the presence of a ServiceMeshMember instance in the model registries namespace named default and that it contains the expected values
  3. Check metrics related to the render action, it should include something like:
    # HELP action_renderer_manifests_total Number of rendered resources
    # TYPE action_renderer_manifests_total counter
    action_renderer_manifests_total{controller="modelregistry",engine="kustomize"} 17
    action_renderer_manifests_total{controller="modelregistry",engine="template"} 1

Screenshot or short clip

Merge criteria

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 73.56322% with 23 lines in your changes missing coverage. Please review.

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

Files with missing lines Patch % Lines
...actions/render/template/action_render_templates.go 73.25% 17 Missing and 6 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## feature-operator-refactor #1364 +/- ## ============================================================ Coverage ? 26.68% ============================================================ Files ? 55 Lines ? 4455 Branches ? 0 ============================================================ Hits ? 1189 Misses ? 3125 Partials ? 141 ```

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

lburgazzoli commented 2 weeks ago

/retest

lburgazzoli commented 2 weeks ago

/retest

lburgazzoli commented 2 weeks ago

/retest

openshift-ci[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grdryn, zdtsw

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)~~ [grdryn,zdtsw] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment