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 ed4ad42 commit b447013
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 getDashboardWatsonResources(ns string) []ResourceSpec {
metadataName := []string{"metadata", "name"}
specAppName := []string{"spec", "appName"}
appName := []string{"watson-studio"}

return []ResourceSpec{
{
Gvk: gvk.OdhQuickStart,
Namespace: ns,
Path: specAppName,
Values: appName,
},
{
Gvk: gvk.OdhDocument,
Namespace: ns,
Path: specAppName,
Values: appName,
},
{
Gvk: gvk.OdhApplication,
Namespace: ns,
Path: metadataName,
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 := getDashboardWatsonResources(dscApplicationsNamespace)
multiErr = multierror.Append(multiErr, deleteResources(ctx, cli, &toDelete))

return multiErr.ErrorOrNil()
}

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

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

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

Expand Down

0 comments on commit b447013

Please sign in to comment.