Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mapping component versions to RHOAI releases #1299

Open
wants to merge 1 commit into
base: incubation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ComponentStatus is meant to hold more information that the release status so I would not conflate different kind of information into a ReleaseStaus struct as it would be misleading.

I would also recommend not to use a map as:

  • the ComponentStatus should be symmetric to the spec. Components in term of naming
  • With a map, it would be extremely easy to accidental break the API


// 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.

35 changes: 35 additions & 0 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ 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"
"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 @@ -72,6 +76,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: version.OperatorVersion{Version: componentVersion},
RepoURL: repositoryURL}

fmt.Print("release object", componentReleaseStatus)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed

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"
"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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to pass a DataScienceCluster instance to the method, so each component can set the related status according to the specif need.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking a little bit more, it may even be moved in the ReconcileComponent method (with some method signature changes)

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
33 changes: 33 additions & 0 deletions components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ 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"
"github.com/operator-framework/api/pkg/lib/version"
corev1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -19,6 +22,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 +86,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: version.OperatorVersion{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
34 changes: 34 additions & 0 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ 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"
"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 @@ -93,6 +96,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: version.OperatorVersion{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
35 changes: 35 additions & 0 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ 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"
"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 @@ -111,6 +115,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: version.OperatorVersion{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
35 changes: 35 additions & 0 deletions components/kueue/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ 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"
"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 @@ -68,6 +72,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: version.OperatorVersion{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
Loading