Skip to content

Commit

Permalink
pkg/upgrade: remove watson-studio dashboard application
Browse files Browse the repository at this point in the history
Jira: https://issues.redhat.com/browse/RHOAIENG-4764

Remove deprecated dashboard resources.
Reuse existing infra just make the array of resources in a separate
function to avoid growing of CleanupExistingResource().

Signed-off-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
ykaliuta committed Apr 9, 2024
1 parent 398f85e commit 3136cde
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/opendatahub-io/opendatahub-operator/v2/components/workbenches"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/gvk"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/metadata/labels"
)

Expand Down Expand Up @@ -265,6 +266,33 @@ func UpdateFromLegacyVersion(cli client.Client, platform deploy.Platform, appNS
return nil
}

func jobGetDashboardWatsonResources(ns string) []JobSpec {
pathName := []string{"metadata", "name"}
pathAppName := []string{"spec", "appName"}
appName := []string{"watson-studio"}

return []JobSpec{
{
Gvk: gvk.OdhQuickStart,
Namespace: ns,
Path: pathAppName,
Values: appName,
},
{
Gvk: gvk.OdhDocument,
Namespace: ns,
Path: pathAppName,
Values: appName,
},
{
Gvk: gvk.OdhApplication,
Namespace: ns,
Path: pathName,
Values: appName,
},
}
}

// TODO: remove function once we have a generic solution across all components.
func CleanupExistingResource(ctx context.Context, cli client.Client, platform deploy.Platform, dscApplicationsNamespace, dscMonitoringNamespace string) error {
var multiErr *multierror.Error
Expand Down Expand Up @@ -308,10 +336,15 @@ func CleanupExistingResource(ctx context.Context, cli client.Client, platform de
Kind: "OdhApplication",
}
multiErr = multierror.Append(multiErr, removOdhApplicationsCR(ctx, cli, JupyterhubApp, "jupyterhub", dscApplicationsNamespace))

// to take a reference
toDelete := jobGetDashboardWatsonResources(dscApplicationsNamespace)
multiErr = multierror.Append(multiErr, deleteResources(ctx, cli, &toDelete))

return multiErr.ErrorOrNil()
}

func deleteResources(ctx context.Context, c client.Client, jobs *[]JobSpec) error { //nolint: deadcode, unused
func deleteResources(ctx context.Context, c client.Client, jobs *[]JobSpec) error {
var errors *multierror.Error

for _, job := range *jobs {
Expand All @@ -322,7 +355,7 @@ func deleteResources(ctx context.Context, c client.Client, jobs *[]JobSpec) erro
return errors.ErrorOrNil()
}

func deleteOneJob(ctx context.Context, c client.Client, job JobSpec) error { //nolint: unused
func deleteOneJob(ctx context.Context, c client.Client, job JobSpec) error {
list := &unstructured.UnstructuredList{}
list.SetGroupVersionKind(job.Gvk)

Expand Down

0 comments on commit 3136cde

Please sign in to comment.