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 11, 2024
1 parent fa63b4d commit 4b85fbc
Show file tree
Hide file tree
Showing 22 changed files with 524 additions and 42 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.ReleaseStatus `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.

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

"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/joho/godotenv"
operatorv1 "github.com/openshift/api/operator/v1"
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"

Check failure on line 21 in components/codeflare/codeflare.go

View workflow job for this annotation

GitHub Actions / golangci-lint

could not import github.com/opendatahub-io/opendatahub-operator/v2/controllers/status (-: # 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 @@ -72,6 +75,37 @@ func (c *CodeFlare) GetComponentName() string {
return ComponentName
}

func (c *CodeFlare) GetComponentStatus() ([]status.ComponentReleaseStatus, error) {
var componentVersion semver.Version
var repositoryURL string
var upstreamReleases = make([]status.ComponentReleaseStatus, 0)

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

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

if err != nil {
fmt.Print("getEnv error", err)
return nil, err
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: CodeflareOperator,
Version: componentVersion,
RepoURL: repositoryURL}

fmt.Print("release object", componentReleaseStatus)
upstreamReleases = append(upstreamReleases, componentReleaseStatus)
return upstreamReleases, nil
}

func (c *CodeFlare) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
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"

Check failure on line 17 in components/component.go

View workflow job for this annotation

GitHub Actions / golangci-lint

could not import github.com/opendatahub-io/opendatahub-operator/v2/controllers/status (-: # 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
GetComponentStatus() ([]status.ComponentReleaseStatus, 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
32 changes: 32 additions & 0 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"fmt"
"path/filepath"

"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/joho/godotenv"
operatorv1 "github.com/openshift/api/operator/v1"
corev1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -19,6 +21,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 +85,35 @@ func (d *Dashboard) GetComponentName() string {
return ComponentNameUpstream
}

func (d *Dashboard) GetComponentStatus() ([]status.ComponentReleaseStatus, error) {
var componentVersion semver.Version
var upstreamReleases = make([]status.ComponentReleaseStatus, 0)
fmt.Print("manifest path", d.DevFlags.Manifests)
env, err := godotenv.Read(filepath.Join(deploy.DefaultManifestPath, ComponentNameUpstream, ".env"))

if err != nil {
fmt.Print("godotenv", err)
return nil, err
}
if env != nil {
componentVersion, err = semver.Parse(env["INTERNAL_RELEASE_VERSION"])

if err != nil {
fmt.Print("getEnv error", err)
return nil, err
}
}
releaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentNameUpstream),
DisplayName: ComponentNameDownstream,
Version: componentVersion,
RepoURL: d.DevFlags.Manifests[0].URI}
fmt.Print("release object", releaseStatus)
// returnDetails.UpstreamReleases = upstreamReleases
upstreamReleases = append(upstreamReleases, releaseStatus)
return upstreamReleases, nil
}

func (d *Dashboard) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
Expand Down
33 changes: 33 additions & 0 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"fmt"
"path/filepath"

"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/joho/godotenv"
operatorv1 "github.com/openshift/api/operator/v1"
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -93,6 +95,37 @@ func (d *DataSciencePipelines) GetComponentName() string {
return ComponentName
}

func (d *DataSciencePipelines) GetComponentStatus() ([]status.ComponentReleaseStatus, error) {
var componentVersion semver.Version
var repositoryURL string
var upstreamReleases = make([]status.ComponentReleaseStatus, 0)

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

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

if err != nil {
fmt.Print("getEnv error", err)
return nil, err
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: componentVersion,
RepoURL: repositoryURL}

fmt.Print("release object", componentReleaseStatus)
upstreamReleases = append(upstreamReleases, componentReleaseStatus)
return upstreamReleases, nil
}

func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
cli client.Client,
l logr.Logger,
Expand Down
34 changes: 34 additions & 0 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ 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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -17,6 +19,7 @@ import (
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 @@ -111,6 +114,37 @@ func (k *Kserve) GetComponentName() string {
return ComponentName
}

func (k *Kserve) GetComponentStatus() ([]status.ComponentReleaseStatus, error) {
var componentVersion semver.Version
var repositoryURL string
var upstreamReleases = make([]status.ComponentReleaseStatus, 0)

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

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

if err != nil {
fmt.Print("getEnv error", err)
return nil, err
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: componentVersion,
RepoURL: repositoryURL}

fmt.Print("release object", componentReleaseStatus)
upstreamReleases = append(upstreamReleases, componentReleaseStatus)
return upstreamReleases, nil
}

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

"github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/joho/godotenv"
operatorv1 "github.com/openshift/api/operator/v1"
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 @@ -68,6 +71,37 @@ func (k *Kueue) GetComponentName() string {
return ComponentName
}

func (k *Kueue) GetComponentStatus() ([]status.ComponentReleaseStatus, error) {
var componentVersion semver.Version
var repositoryURL string
var upstreamReleases = make([]status.ComponentReleaseStatus, 0)

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

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

if err != nil {
fmt.Print("getEnv error", err)
return nil, err
}
repositoryURL = env["REPOSITORY_URL"]
}
componentReleaseStatus := status.ComponentReleaseStatus{
Name: status.Platform(ComponentName),
DisplayName: ComponentName,
Version: componentVersion,
RepoURL: repositoryURL}

fmt.Print("release object", componentReleaseStatus)
upstreamReleases = append(upstreamReleases, componentReleaseStatus)
return upstreamReleases, nil
}

func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client, l logr.Logger,
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
enabled := k.GetManagementState() == operatorv1.Managed
Expand Down
Loading

0 comments on commit 4b85fbc

Please sign in to comment.