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 20, 2024
1 parent 0c16075 commit 210bde1
Show file tree
Hide file tree
Showing 22 changed files with 493 additions and 58 deletions.
8 changes: 1 addition & 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 map[string]status.ComponentStatus `json:"components,omitempty"`

// Version and release type
Release cluster.Release `json:"release,omitempty"`
Expand Down
28 changes: 7 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.

33 changes: 33 additions & 0 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import (
"fmt"
"path/filepath"

"github.com/blang/semver/v4"
"github.com/joho/godotenv"
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"
"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,6 +75,35 @@ func (c *CodeFlare) GetComponentName() string {
return ComponentName
}

func (c *CodeFlare) GetUpstreamReleaseStatus() status.UpstreamReleases {
var componentVersion semver.Version
var repositoryURL string
var releaseDetails = make([]status.ComponentReleaseStatus, 0)
var releaseStatus status.UpstreamReleases

env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env"))

if err != nil {
return status.UpstreamReleases{}
}
if env != nil {
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"])

if err != nil {
return status.UpstreamReleases{}
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: CodeflareOperator,
Version: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}
releaseDetails = append(releaseDetails, componentReleaseStatus)
releaseStatus.UpstreamRelease = releaseDetails
return releaseStatus
}

func (c *CodeFlare) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
Expand Down
2 changes: 2 additions & 0 deletions components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"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 @@ -86,6 +87,7 @@ type ComponentInterface interface {
owner metav1.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
GetUpstreamReleaseStatus() status.UpstreamReleases
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
5 changes: 5 additions & 0 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

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,6 +83,10 @@ func (d *Dashboard) GetComponentName() string {
return ComponentNameUpstream
}

func (d *Dashboard) GetUpstreamReleaseStatus() status.UpstreamReleases {
return status.UpstreamReleases{}
}

func (d *Dashboard) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
Expand Down
32 changes: 32 additions & 0 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
"fmt"
"path/filepath"

"github.com/blang/semver/v4"
"github.com/joho/godotenv"
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"
Expand Down Expand Up @@ -92,6 +95,35 @@ func (d *DataSciencePipelines) GetComponentName() string {
return ComponentName
}

func (d *DataSciencePipelines) GetUpstreamReleaseStatus() status.UpstreamReleases {
var componentVersion semver.Version
var repositoryURL string
var releaseDetails = make([]status.ComponentReleaseStatus, 0)
var releaseStatus status.UpstreamReleases

env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env"))

if err != nil {
return status.UpstreamReleases{}
}
if env != nil {
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"])

if err != nil {
return status.UpstreamReleases{}
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}
releaseDetails = append(releaseDetails, componentReleaseStatus)
releaseStatus.UpstreamRelease = releaseDetails
return releaseStatus
}

func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
Expand Down
33 changes: 33 additions & 0 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import (
"path/filepath"
"strings"

"github.com/blang/semver/v4"
"github.com/joho/godotenv"
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,6 +114,35 @@ func (k *Kserve) GetComponentName() string {
return ComponentName
}

func (k *Kserve) GetUpstreamReleaseStatus() status.UpstreamReleases {
var componentVersion semver.Version
var repositoryURL string
var releaseDetails = make([]status.ComponentReleaseStatus, 0)
var releaseStatus status.UpstreamReleases

env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env"))

if err != nil {
return status.UpstreamReleases{}
}
if env != nil {
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"])

if err != nil {
return status.UpstreamReleases{}
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}
releaseDetails = append(releaseDetails, componentReleaseStatus)
releaseStatus.UpstreamRelease = releaseDetails
return releaseStatus
}

func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
l := logf.FromContext(ctx)
Expand Down
33 changes: 33 additions & 0 deletions components/kueue/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import (
"fmt"
"path/filepath"

"github.com/blang/semver/v4"
"github.com/joho/godotenv"
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"
"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,6 +71,35 @@ func (k *Kueue) GetComponentName() string {
return ComponentName
}

func (k *Kueue) GetUpstreamReleaseStatus() status.UpstreamReleases {
var componentVersion semver.Version
var repositoryURL string
var releaseDetails = make([]status.ComponentReleaseStatus, 0)
var releaseStatus status.UpstreamReleases

env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env"))

if err != nil {
return status.UpstreamReleases{}
}
if env != nil {
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"])

if err != nil {
return status.UpstreamReleases{}
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}
releaseDetails = append(releaseDetails, componentReleaseStatus)
releaseStatus.UpstreamRelease = releaseDetails
return releaseStatus
}

func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client,
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
l := logf.FromContext(ctx)
Expand Down
33 changes: 33 additions & 0 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import (
"path/filepath"
"strings"

"github.com/blang/semver/v4"
"github.com/joho/godotenv"
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"
"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,6 +104,35 @@ func (m *ModelMeshServing) GetComponentName() string {
return ComponentName
}

func (m *ModelMeshServing) GetUpstreamReleaseStatus() status.UpstreamReleases {
var componentVersion semver.Version
var repositoryURL string
var releaseDetails = make([]status.ComponentReleaseStatus, 0)
var releaseStatus status.UpstreamReleases

env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentName, ".env"))

if err != nil {
return status.UpstreamReleases{}
}
if env != nil {
componentVersion, err = semver.Parse(env["UPSTREAM_RELEASE_VERSION"])

if err != nil {
return status.UpstreamReleases{}
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}
releaseDetails = append(releaseDetails, componentReleaseStatus)
releaseStatus.UpstreamRelease = releaseDetails
return releaseStatus
}

func (m *ModelMeshServing) ReconcileComponent(ctx context.Context,
cli client.Client,
owner metav1.Object,
Expand Down
Loading

0 comments on commit 210bde1

Please sign in to comment.