Skip to content

Commit

Permalink
Remove component status when component is not managed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara4994 committed Oct 26, 2024
1 parent b0c6ab4 commit e311476
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 48 deletions.
11 changes: 8 additions & 3 deletions components/codeflare/codeflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ func (c *CodeFlare) GetComponentName() string {
}

func (c *CodeFlare) UpdateStatus(in *status.ComponentsStatus) {
codeFlareStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := c.GetManagementState() == operatorv1.Managed
if enabled {
codeFlareStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.CodeFlare = &status.CodeFlareStatus{
ComponentStatus: codeFlareStatus,
in.CodeFlare = &status.CodeFlareStatus{
ComponentStatus: codeFlareStatus,
}
} else {
in.CodeFlare = nil
}
}

Expand Down
8 changes: 7 additions & 1 deletion components/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ func (d *Dashboard) GetComponentName() string {
}

func (d *Dashboard) UpdateStatus(in *status.ComponentsStatus) {
in.Dashboard = &status.DashboardStatus{}
enabled := d.GetManagementState() == operatorv1.Managed

if enabled {
in.Dashboard = &status.DashboardStatus{}
} else {
in.Dashboard = nil
}
}

func (d *Dashboard) ReconcileComponent(ctx context.Context,
Expand Down
11 changes: 8 additions & 3 deletions components/datasciencepipelines/datasciencepipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@ func (d *DataSciencePipelines) GetComponentName() string {
}

func (d *DataSciencePipelines) UpdateStatus(in *status.ComponentsStatus) {
dataSciencePipelinesStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := d.GetManagementState() == operatorv1.Managed
if enabled {
dataSciencePipelinesStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.DataSciencePipelines = &status.DataSciencePipelinesStatus{
ComponentStatus: dataSciencePipelinesStatus,
in.DataSciencePipelines = &status.DataSciencePipelinesStatus{
ComponentStatus: dataSciencePipelinesStatus,
}
} else {
in.DataSciencePipelines = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/kserve/kserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ func (k *Kserve) GetComponentName() string {
}

func (k *Kserve) UpdateStatus(in *status.ComponentsStatus) {
kserveStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := k.GetManagementState() == operatorv1.Managed
if enabled {
kserveStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.Kserve = &status.KserveStatus{
ComponentStatus: kserveStatus,
in.Kserve = &status.KserveStatus{
ComponentStatus: kserveStatus,
}
} else {
in.Kserve = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/kueue/kueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ func (k *Kueue) GetComponentName() string {
}

func (k *Kueue) UpdateStatus(in *status.ComponentsStatus) {
kueueStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := k.GetManagementState() == operatorv1.Managed
if enabled {
kueueStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.Kueue = &status.KueueStatus{
ComponentStatus: kueueStatus,
in.Kueue = &status.KueueStatus{
ComponentStatus: kueueStatus,
}
} else {
in.Kueue = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/modelmeshserving/modelmeshserving.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,15 @@ func (m *ModelMeshServing) GetComponentName() string {
}

func (m *ModelMeshServing) UpdateStatus(in *status.ComponentsStatus) {
modelMeshServingStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := m.GetManagementState() == operatorv1.Managed
if enabled {
modelMeshServingStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.ModelMeshServing = &status.ModelMeshServingStatus{
ComponentStatus: modelMeshServingStatus,
in.ModelMeshServing = &status.ModelMeshServingStatus{
ComponentStatus: modelMeshServingStatus,
}
} else {
in.ModelMeshServing = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/modelregistry/modelregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,15 @@ func (m *ModelRegistry) GetComponentName() string {
}

func (m *ModelRegistry) UpdateStatus(in *status.ComponentsStatus) {
modelRegistryStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := m.GetManagementState() == operatorv1.Managed
if enabled {
modelRegistryStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.ModelRegistry = &status.ModelRegistryStatus{
ComponentStatus: modelRegistryStatus,
in.ModelRegistry = &status.ModelRegistryStatus{
ComponentStatus: modelRegistryStatus,
}
} else {
in.ModelRegistry = &status.ModelRegistryStatus{}
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/ray/ray.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,15 @@ func (r *Ray) GetComponentName() string {
}

func (r *Ray) UpdateStatus(in *status.ComponentsStatus) {
rayStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := r.GetManagementState() == operatorv1.Managed
if enabled {
rayStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.Ray = &status.RayStatus{
ComponentStatus: rayStatus,
in.Ray = &status.RayStatus{
ComponentStatus: rayStatus,
}
} else {
in.Ray = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/trainingoperator/trainingoperator.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ func (r *TrainingOperator) GetComponentName() string {
}

func (r *TrainingOperator) UpdateStatus(in *status.ComponentsStatus) {
trainingOperatorStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := r.GetManagementState() == operatorv1.Managed
if enabled {
trainingOperatorStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.TrainingOperator = &status.TrainingOperatorStatus{
ComponentStatus: trainingOperatorStatus,
in.TrainingOperator = &status.TrainingOperatorStatus{
ComponentStatus: trainingOperatorStatus,
}
} else {
in.TrainingOperator = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/trustyai/trustyai.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ func (t *TrustyAI) GetComponentName() string {
}

func (t *TrustyAI) UpdateStatus(in *status.ComponentsStatus) {
trustyAIStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := t.GetManagementState() == operatorv1.Managed
if enabled {
trustyAIStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.TrustyAI = &status.TrustyAIStatus{
ComponentStatus: trustyAIStatus,
in.TrustyAI = &status.TrustyAIStatus{
ComponentStatus: trustyAIStatus,
}
} else {
in.TrustyAI = nil
}
}

Expand Down
11 changes: 8 additions & 3 deletions components/workbenches/workbenches.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ func (w *Workbenches) GetComponentName() string {
}

func (w *Workbenches) UpdateStatus(in *status.ComponentsStatus) {
workbenchesStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)
enabled := w.GetManagementState() == operatorv1.Managed
if enabled {
workbenchesStatus := status.GetReleaseVersion(deploy.DefaultManifestPath, ComponentName)

in.Workbenches = &status.WorkbenchesStatus{
ComponentStatus: workbenchesStatus,
in.Workbenches = &status.WorkbenchesStatus{
ComponentStatus: workbenchesStatus,
}
} else {
in.Workbenches = nil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ spec:
properties:
codeflare:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -671,7 +671,7 @@ spec:
type: object
dashboard:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -690,7 +690,7 @@ spec:
type: object
datasciencepipelines:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -709,7 +709,7 @@ spec:
type: object
kserve:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -728,7 +728,7 @@ spec:
type: object
kueue:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -747,7 +747,7 @@ spec:
type: object
modelmeshserving:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -768,7 +768,7 @@ spec:
properties:
registriesNamespace:
type: string
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -787,7 +787,7 @@ spec:
type: object
ray:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -806,7 +806,7 @@ spec:
type: object
trainingoperator:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -825,7 +825,7 @@ spec:
type: object
trustyai:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand All @@ -844,7 +844,7 @@ spec:
type: object
workbenches:
properties:
upstreamrelease:
releases:
items:
description: |-
Condition represents the state of the operator's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ func (r *DataScienceClusterReconciler) reconcileSubComponent(ctx context.Context
saved.Status.InstalledComponents = make(map[string]bool)
}
saved.Status.InstalledComponents[componentName] = enabled
component.UpdateStatus(&saved.Status.Components)
if enabled {
component.UpdateStatus(&saved.Status.Components)
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileCompleted, "Component reconciled successfully", corev1.ConditionTrue)
} else {
status.RemoveComponentCondition(&saved.Status.Conditions, componentName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
. "github.com/onsi/gomega"
)

func newFakeClient(objs ...client.Object) client.Client { //nolint:ireturn
func newFakeClient(objs ...client.Object) client.Client {
scheme := runtime.NewScheme()
utilruntime.Must(corev1.AddToScheme(scheme))
utilruntime.Must(appsv1.AddToScheme(scheme))
Expand Down
4 changes: 2 additions & 2 deletions controllers/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ type ComponentReleaseStatus struct {

// +k8s:deepcopy-gen=true
type ComponentStatus struct {
UpstreamReleases []ComponentReleaseStatus `json:"upstreamrelease,omitempty"`
Releases []ComponentReleaseStatus `json:"releases,omitempty"`
}

// +k8s:deepcopy-gen=true
Expand Down Expand Up @@ -323,7 +323,7 @@ func GetReleaseVersion(defaultManifestPath string, componentName string) Compone
displayName = env["DISPLAY_NAME"]

return ComponentStatus{
UpstreamReleases: []ComponentReleaseStatus{{
Releases: []ComponentReleaseStatus{{
Name: componentName,
DisplayName: displayName,
Version: version.OperatorVersion{Version: componentVersion},
Expand Down
4 changes: 2 additions & 2 deletions controllers/status/zz_generated.deepcopy.go

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

0 comments on commit e311476

Please sign in to comment.