Skip to content

Commit 8181671

Browse files
committed
feat: Mapping component versions to RHOAI releases
1 parent 0c16075 commit 8181671

File tree

23 files changed

+937
-73
lines changed

23 files changed

+937
-73
lines changed

Dockerfiles/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ COPY main.go main.go
3939
COPY pkg/ pkg/
4040

4141
# Build
42-
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
42+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
4343

4444
################################################################################
4545
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

apis/datasciencecluster/v1/datasciencecluster_types.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ type Components struct {
8787
TrainingOperator trainingoperator.TrainingOperator `json:"trainingoperator,omitempty"`
8888
}
8989

90-
// ComponentsStatus defines the custom status of DataScienceCluster components.
91-
type ComponentsStatus struct {
92-
// ModelRegistry component status
93-
ModelRegistry *status.ModelRegistryStatus `json:"modelregistry,omitempty"`
94-
}
95-
9690
// DataScienceClusterStatus defines the observed state of DataScienceCluster.
9791
type DataScienceClusterStatus struct {
9892
// Phase describes the Phase of DataScienceCluster reconciliation state
@@ -114,7 +108,7 @@ type DataScienceClusterStatus struct {
114108

115109
// Expose component's specific status
116110
// +optional
117-
Components ComponentsStatus `json:"components,omitempty"`
111+
Components status.ComponentsStatus `json:"components,omitempty"`
118112

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

168162
return allComponents, nil
169163
}
164+
165+
func (d *DataScienceCluster) GetComponentsStatus() *status.ComponentsStatus {
166+
return &d.Status.Components
167+
}

apis/datasciencecluster/v1/zz_generated.deepcopy.go

-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/codeflare/codeflare.go

+26-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
"path/filepath"
1010

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

1616
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
1717
"github.com/opendatahub-io/opendatahub-operator/v2/components"
18+
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
1819
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
1920
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
2021
)
@@ -71,9 +72,32 @@ func (c *CodeFlare) GetComponentName() string {
7172
return ComponentName
7273
}
7374

75+
func (c *CodeFlare) UpdateStatus(in *status.ComponentsStatus) error {
76+
codeFlareStatus, err := c.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)
77+
78+
if err != nil {
79+
in.CodeFlare = &status.CodeFlareStatus{}
80+
return err
81+
}
82+
83+
in.CodeFlare = &status.CodeFlareStatus{
84+
ComponentStatus: status.ComponentStatus{
85+
UpstreamRelease: []status.ComponentReleaseStatus{{
86+
Name: status.Platform(ComponentName),
87+
DisplayName: CodeflareOperator,
88+
Version: version.OperatorVersion{Version: codeFlareStatus.ComponentVersion},
89+
RepoURL: codeFlareStatus.RepositoryURL,
90+
},
91+
},
92+
},
93+
}
94+
95+
return nil
96+
}
97+
7498
func (c *CodeFlare) ReconcileComponent(ctx context.Context,
7599
cli client.Client,
76-
owner metav1.Object,
100+
owner client.Object,
77101
dscispec *dsciv1.DSCInitializationSpec,
78102
platform cluster.Platform,
79103
_ bool) error {

components/component.go

+31-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import (
77
"path/filepath"
88
"strings"
99

10+
"github.com/blang/semver/v4"
1011
"github.com/go-logr/logr"
12+
"github.com/joho/godotenv"
1113
operatorv1 "github.com/openshift/api/operator/v1"
1214
"gopkg.in/yaml.v2"
1315
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1416
"sigs.k8s.io/controller-runtime/pkg/client"
1517

1618
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
19+
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
1720
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
1821
)
1922

@@ -80,12 +83,18 @@ type ManifestsConfig struct {
8083
SourcePath string `json:"sourcePath,omitempty"`
8184
}
8285

86+
type ComponentReleaseDetails struct {
87+
ComponentVersion semver.Version
88+
RepositoryURL string
89+
}
90+
8391
type ComponentInterface interface {
8492
Init(ctx context.Context, platform cluster.Platform) error
85-
ReconcileComponent(ctx context.Context, cli client.Client,
86-
owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec, platform cluster.Platform, currentComponentStatus bool) error
93+
ReconcileComponent(ctx context.Context, cli client.Client, owner client.Object, DSCISpec *dsciv1.DSCInitializationSpec,
94+
platform cluster.Platform, currentComponentStatus bool) error
8795
Cleanup(ctx context.Context, cli client.Client, owner metav1.Object, DSCISpec *dsciv1.DSCInitializationSpec) error
8896
GetComponentName() string
97+
UpdateStatus(status *status.ComponentsStatus) error
8998
GetManagementState() operatorv1.ManagementState
9099
OverrideManifests(ctx context.Context, platform cluster.Platform) error
91100
UpdatePrometheusConfig(cli client.Client, logger logr.Logger, enable bool, component string) error
@@ -195,3 +204,23 @@ func (c *Component) UpdatePrometheusConfig(_ client.Client, logger logr.Logger,
195204

196205
return err
197206
}
207+
208+
func (c *Component) GetReleaseVersion(in *status.ComponentsStatus, defaultManifestPath string, componentName string) (ComponentReleaseDetails, error) {
209+
var componentVersion semver.Version
210+
var repositoryURL string
211+
212+
env, err := godotenv.Read(filepath.Join(defaultManifestPath, componentName, ".env"))
213+
214+
if err != nil {
215+
return ComponentReleaseDetails{}, err
216+
}
217+
218+
componentVersion, err = semver.Parse(env["RHOAI_RELEASE_VERSION"])
219+
220+
if err != nil {
221+
return ComponentReleaseDetails{}, err
222+
}
223+
repositoryURL = env["REPOSITORY_URL"]
224+
225+
return ComponentReleaseDetails{ComponentVersion: componentVersion, RepositoryURL: repositoryURL}, nil
226+
}

components/dashboard/dashboard.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import (
1313
operatorv1 "github.com/openshift/api/operator/v1"
1414
corev1 "k8s.io/api/core/v1"
1515
k8serr "k8s.io/apimachinery/pkg/api/errors"
16-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1716
"sigs.k8s.io/controller-runtime/pkg/client"
1817
logf "sigs.k8s.io/controller-runtime/pkg/log"
1918

2019
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
2120
"github.com/opendatahub-io/opendatahub-operator/v2/components"
21+
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
2222
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2323
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
2424
)
@@ -82,9 +82,14 @@ func (d *Dashboard) GetComponentName() string {
8282
return ComponentNameUpstream
8383
}
8484

85+
func (d *Dashboard) UpdateStatus(in *status.ComponentsStatus) error {
86+
in.Dashboard = &status.DashboardStatus{}
87+
return nil
88+
}
89+
8590
func (d *Dashboard) ReconcileComponent(ctx context.Context,
8691
cli client.Client,
87-
owner metav1.Object,
92+
owner client.Object,
8893
dscispec *dsciv1.DSCInitializationSpec,
8994
platform cluster.Platform,
9095
currentComponentExist bool,

components/datasciencepipelines/datasciencepipelines.go

+25-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010

1111
operatorv1 "github.com/openshift/api/operator/v1"
1212
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
13+
"github.com/operator-framework/api/pkg/lib/version"
1314
corev1 "k8s.io/api/core/v1"
1415
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1516
k8serr "k8s.io/apimachinery/pkg/api/errors"
16-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1717
"sigs.k8s.io/controller-runtime/pkg/client"
1818
logf "sigs.k8s.io/controller-runtime/pkg/log"
1919

@@ -92,9 +92,32 @@ func (d *DataSciencePipelines) GetComponentName() string {
9292
return ComponentName
9393
}
9494

95+
func (d *DataSciencePipelines) UpdateStatus(in *status.ComponentsStatus) error {
96+
dataSciencePipelinesStatus, err := d.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)
97+
98+
if err != nil {
99+
in.DataSciencePipelines = &status.DataSciencePipelinesStatus{}
100+
return err
101+
}
102+
103+
in.DataSciencePipelines = &status.DataSciencePipelinesStatus{
104+
ComponentStatus: status.ComponentStatus{
105+
UpstreamRelease: []status.ComponentReleaseStatus{{
106+
Name: status.Platform(ComponentName),
107+
DisplayName: ComponentName,
108+
Version: version.OperatorVersion{Version: dataSciencePipelinesStatus.ComponentVersion},
109+
RepoURL: dataSciencePipelinesStatus.RepositoryURL,
110+
},
111+
},
112+
},
113+
}
114+
115+
return nil
116+
}
117+
95118
func (d *DataSciencePipelines) ReconcileComponent(ctx context.Context,
96119
cli client.Client,
97-
owner metav1.Object,
120+
owner client.Object,
98121
dscispec *dsciv1.DSCInitializationSpec,
99122
platform cluster.Platform,
100123
_ bool,

components/kserve/kserve.go

+26-1
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
"strings"
1010

1111
operatorv1 "github.com/openshift/api/operator/v1"
12+
"github.com/operator-framework/api/pkg/lib/version"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314
"sigs.k8s.io/controller-runtime/pkg/client"
1415
logf "sigs.k8s.io/controller-runtime/pkg/log"
1516

1617
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
1718
infrav1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/infrastructure/v1"
1819
"github.com/opendatahub-io/opendatahub-operator/v2/components"
20+
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
1921
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
2022
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
2123
)
@@ -110,8 +112,31 @@ func (k *Kserve) GetComponentName() string {
110112
return ComponentName
111113
}
112114

115+
func (k *Kserve) UpdateStatus(in *status.ComponentsStatus) error {
116+
kserveStatus, err := k.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)
117+
118+
if err != nil {
119+
in.Kserve = &status.KserveStatus{}
120+
return err
121+
}
122+
123+
in.Kserve = &status.KserveStatus{
124+
ComponentStatus: status.ComponentStatus{
125+
UpstreamRelease: []status.ComponentReleaseStatus{{
126+
Name: status.Platform(ComponentName),
127+
DisplayName: ComponentName,
128+
Version: version.OperatorVersion{Version: kserveStatus.ComponentVersion},
129+
RepoURL: kserveStatus.RepositoryURL,
130+
},
131+
},
132+
},
133+
}
134+
135+
return nil
136+
}
137+
113138
func (k *Kserve) ReconcileComponent(ctx context.Context, cli client.Client,
114-
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
139+
owner client.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
115140
l := logf.FromContext(ctx)
116141
enabled := k.GetManagementState() == operatorv1.Managed
117142
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

components/kueue/kueue.go

+25-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"path/filepath"
88

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

1414
dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1"
1515
"github.com/opendatahub-io/opendatahub-operator/v2/components"
16+
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
1617
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
1718
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
1819
)
@@ -67,8 +68,30 @@ func (k *Kueue) GetComponentName() string {
6768
return ComponentName
6869
}
6970

71+
func (k *Kueue) UpdateStatus(in *status.ComponentsStatus) error {
72+
kueueStatus, err := k.GetReleaseVersion(in, deploy.DefaultManifestPath, ComponentName)
73+
74+
if err != nil {
75+
in.Kueue = &status.KueueStatus{}
76+
return err
77+
}
78+
in.Kueue = &status.KueueStatus{
79+
ComponentStatus: status.ComponentStatus{
80+
UpstreamRelease: []status.ComponentReleaseStatus{{
81+
Name: status.Platform(ComponentName),
82+
DisplayName: ComponentName,
83+
Version: version.OperatorVersion{Version: kueueStatus.ComponentVersion},
84+
RepoURL: kueueStatus.RepositoryURL,
85+
},
86+
},
87+
},
88+
}
89+
90+
return nil
91+
}
92+
7093
func (k *Kueue) ReconcileComponent(ctx context.Context, cli client.Client,
71-
owner metav1.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
94+
owner client.Object, dscispec *dsciv1.DSCInitializationSpec, platform cluster.Platform, _ bool) error {
7295
l := logf.FromContext(ctx)
7396
enabled := k.GetManagementState() == operatorv1.Managed
7497
monitoringEnabled := dscispec.Monitoring.ManagementState == operatorv1.Managed

0 commit comments

Comments
 (0)