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(). Because of
that moved pathName to a file scope to reuse.

Signed-off-by: Yauheni Kaliuta <[email protected]>
  • Loading branch information
ykaliuta committed Apr 8, 2024
1 parent d0bf97e commit 5bb54af
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ var (
gvkServiceAccount = schema.GroupVersionKind{Group: "", Version: "v1", Kind: "ServiceAccount"}
gvkServiceMonitor = schema.GroupVersionKind{Group: "monitoring.coreos.com", Version: "v1", Kind: "ServiceMonitor"}
gvkOdhApplication = schema.GroupVersionKind{Group: "dashboard.opendatahub.io", Version: "v1", Kind: "OdhApplication"}
gvkOdhQuickStart = schema.GroupVersionKind{Group: "console.openshift.io", Version: "v1", Kind: "OdhQuickStart"}
gvkOdhDocument = schema.GroupVersionKind{Group: "dashboard.opendatahub.io", Version: "v1", Kind: "OdhDocument"}

pathName = []string{"metadata", "name"}
)

// CreateDefaultDSC creates a default instance of DSC.
Expand Down Expand Up @@ -273,11 +277,36 @@ func UpdateFromLegacyVersion(cli client.Client, platform deploy.Platform, appNS
return nil
}

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

return []JobSpec{
{
Gvk: gvkOdhQuickStart,
Namespace: ns,
Path: pathAppName,
Values: appName,
},
{
Gvk: gvkOdhDocument,
Namespace: ns,
Path: pathAppName,
Values: appName,
},
{
Gvk: gvkOdhApplication,
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
var toDelete []JobSpec
pathName := []string{"metadata", "name"}
// Special Handling of cleanup of deprecated model monitoring stack
if platform == deploy.ManagedRhods {
del := []JobSpec{
Expand Down Expand Up @@ -348,6 +377,7 @@ func CleanupExistingResource(ctx context.Context, cli client.Client, platform de
}

toDelete = append(toDelete, del)
toDelete = append(toDelete, jobGetDashboardWatsonResources(dscApplicationsNamespace)...)

multiErr = multierror.Append(multiErr, deleteResources(ctx, cli, &toDelete))

Expand Down

0 comments on commit 5bb54af

Please sign in to comment.