Skip to content

Commit

Permalink
feat: Mapping component versions to RHOAI releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara4994 committed Oct 21, 2024
1 parent 0c16075 commit f3bb873
Show file tree
Hide file tree
Showing 22 changed files with 923 additions and 71 deletions.
12 changes: 5 additions & 7 deletions apis/datasciencecluster/v1/datasciencecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ type Components struct {
TrainingOperator trainingoperator.TrainingOperator `json:"trainingoperator,omitempty"`
}

// ComponentsStatus defines the custom status of DataScienceCluster components.
type ComponentsStatus struct {
// ModelRegistry component status
ModelRegistry *status.ModelRegistryStatus `json:"modelregistry,omitempty"`
}

// DataScienceClusterStatus defines the observed state of DataScienceCluster.
type DataScienceClusterStatus struct {
// Phase describes the Phase of DataScienceCluster reconciliation state
Expand All @@ -114,7 +108,7 @@ type DataScienceClusterStatus struct {

// Expose component's specific status
// +optional
Components ComponentsStatus `json:"components,omitempty"`
Components status.ComponentsStatus `json:"components,omitempty"`

// Version and release type
Release cluster.Release `json:"release,omitempty"`
Expand Down Expand Up @@ -167,3 +161,7 @@ func (d *DataScienceCluster) GetComponents() ([]components.ComponentInterface, e

return allComponents, nil
}

func (d *DataScienceCluster) GetComponentsStatus() *status.ComponentsStatus {
return &d.Status.Components
}
21 changes: 0 additions & 21 deletions apis/datasciencecluster/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"path/filepath"

operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/operator-framework/api/pkg/lib/version"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
)
Expand Down Expand Up @@ -71,9 +72,32 @@ func (c *CodeFlare) GetComponentName() string {
return ComponentName
}

func (c *CodeFlare) UpdateStatus(in *status.ComponentsStatus) error {
codeFlareStatus, err := c.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)

if err != nil {
in.CodeFlare = &status.CodeFlareStatus{}
return err
}

in.CodeFlare = &status.CodeFlareStatus{
ComponentStatus: status.ComponentStatus{
UpstreamRelease: []status.ComponentReleaseStatus{{
Name: status.Platform(ComponentName),
DisplayName: CodeflareOperator,
Version: version.OperatorVersion{Version: codeFlareStatus.ComponentVersion},
RepoURL: codeFlareStatus.RepositoryURL,
},
},
},
}

return nil
}

func (c *CodeFlare) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
owner client.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
_ bool) error {
Expand Down
33 changes: 31 additions & 2 deletions components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import (
"path/filepath"
"strings"

"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/joho/godotenv"
operatorv1 "github.com/openshift/api/operator/v1"
"gopkg.in/yaml.v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/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/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
)

Expand Down Expand Up @@ -80,12 +83,18 @@ type ManifestsConfig struct {
SourcePath string `json:"sourcePath,omitempty"`
}

type ComponentReleaseDetails struct {
ComponentVersion semver.Version
RepositoryURL string
}

type ComponentInterface interface {
Init(ctx context.Context, platform cluster.Platform) error
ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error
ReconcileComponent(ctx context.Context, cli client.Client, owner client.Object, DSCISpec *dsciv1.DSCInitializationSpec,
platform cluster.Platform, currentComponentStatus bool) error
Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error
GetComponentName() string
UpdateStatus(status *status.ComponentsStatus) error
GetManagementState() operatorv1.ManagementState
OverrideManifests(ctx context.Context, platform cluster.Platform) error
UpdatePrometheusConfig(cli client.Client, logger logr.Logger, enable bool, component string) error
Expand Down Expand Up @@ -195,3 +204,23 @@ func (c *Component) UpdatePrometheusConfig(_ client.Client, logger logr.Logger,

return err
}

func (c *Component) GetReleaseVersion(in *status.ComponentsStatus, defaultManifestPath string, componentName string) (ComponentReleaseDetails, error) {
var componentVersion semver.Version
var repositoryURL string

env, err := godotenv.Read(filepath.Join(defaultManifestPath, componentName, ".env"))

if err != nil {
return ComponentReleaseDetails{}, err
}

componentVersion, err = semver.Parse(env["RHOAI_RELEASE_VERSION"])

if err != nil {
return ComponentReleaseDetails{}, err
}
repositoryURL = env["REPOSITORY_URL"]

return ComponentReleaseDetails{ComponentVersion: componentVersion, RepositoryURL: repositoryURL}, nil
}
9 changes: 7 additions & 2 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
operatorv1 "github.com/openshift/api/operator/v1"
corev1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
)
Expand Down Expand Up @@ -82,9 +82,14 @@ func (d *Dashboard) GetComponentName() string {
return ComponentNameUpstream
}

func (d *Dashboard) UpdateStatus(in *status.ComponentsStatus) error {
in.Dashboard = &status.DashboardStatus{}
return nil
}

func (d *Dashboard) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
owner client.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
currentComponentExist bool,
Expand Down
27 changes: 25 additions & 2 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

operatorv1 "github.com/openshift/api/operator/v1"
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
"github.com/operator-framework/api/pkg/lib/version"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

Expand Down Expand Up @@ -92,9 +92,32 @@ func (d *DataSciencePipelines) GetComponentName() string {
return ComponentName
}

func (d *DataSciencePipelines) UpdateStatus(in *status.ComponentsStatus) error {
dataSciencePipelinesStatus, err := d.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)

if err != nil {
in.DataSciencePipelines = &status.DataSciencePipelinesStatus{}
return err
}

in.DataSciencePipelines = &status.DataSciencePipelinesStatus{
ComponentStatus: status.ComponentStatus{
UpstreamRelease: []status.ComponentReleaseStatus{{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: dataSciencePipelinesStatus.ComponentVersion},
RepoURL: dataSciencePipelinesStatus.RepositoryURL,
},
},
},
}

return nil
}

func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
owner client.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
_ bool,
Expand Down
27 changes: 26 additions & 1 deletion components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (
"strings"

operatorv1 "github.com/openshift/api/operator/v1"
"github.com/operator-framework/api/pkg/lib/version"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
)
Expand Down Expand Up @@ -110,8 +112,31 @@ func (k *Kserve) GetComponentName() string {
return ComponentName
}

func (k *Kserve) UpdateStatus(in *status.ComponentsStatus) error {
kserveStatus, err := k.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)

if err != nil {
in.Kserve = &status.KserveStatus{}
return err
}

in.Kserve = &status.KserveStatus{
ComponentStatus: status.ComponentStatus{
UpstreamRelease: []status.ComponentReleaseStatus{{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: kserveStatus.ComponentVersion},
RepoURL: kserveStatus.RepositoryURL,
},
},
},
}

return nil
}

func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
owner client.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
l := logf.FromContext(ctx)
enabled := k.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
Expand Down
27 changes: 25 additions & 2 deletions components/kueue/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"path/filepath"

operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/operator-framework/api/pkg/lib/version"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
)
Expand Down Expand Up @@ -67,8 +68,30 @@ func (k *Kueue) GetComponentName() string {
return ComponentName
}

func (k *Kueue) UpdateStatus(in *status.ComponentsStatus) error {
kueueStatus, err := k.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)

if err != nil {
in.Kueue = &status.KueueStatus{}
return err
}
in.Kueue = &status.KueueStatus{
ComponentStatus: status.ComponentStatus{
UpstreamRelease: []status.ComponentReleaseStatus{{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: kueueStatus.ComponentVersion},
RepoURL: kueueStatus.RepositoryURL,
},
},
},
}

return nil
}

func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
owner client.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
l := logf.FromContext(ctx)
enabled := k.GetManagementState() == operatorv1.Managed
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed
Expand Down
28 changes: 26 additions & 2 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"strings"

operatorv1 "github.com/openshift/api/operator/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/operator-framework/api/pkg/lib/version"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
"github.com/opendatahub-io/opendatahub-operator/v2/components"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
)
Expand Down Expand Up @@ -100,9 +101,32 @@ func (m *ModelMeshServing) GetComponentName() string {
return ComponentName
}

func (m *ModelMeshServing) UpdateStatus(in *status.ComponentsStatus) error {
modelMeshServingStatus, err := m.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)

if err != nil {
in.ModelMeshServing = &status.ModelMeshServingStatus{}
return err
}

in.ModelMeshServing = &status.ModelMeshServingStatus{
ComponentStatus: status.ComponentStatus{
UpstreamRelease: []status.ComponentReleaseStatus{{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: modelMeshServingStatus.ComponentVersion},
RepoURL: modelMeshServingStatus.RepositoryURL,
},
},
},
}

return nil
}

func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
owner client.Object,
dscispec *dsciv1.DSCInitializationSpec,
platform cluster.Platform,
_ bool,
Expand Down
Loading

0 comments on commit f3bb873

Please sign in to comment.