Skip to content

Commit

Permalink
feat(cleanup): remove jupyterhub OdhDocument CR from previous release (
Browse files Browse the repository at this point in the history
…opendatahub-io#991)

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw authored May 7, 2024
1 parent a107703 commit 6f90d70
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
6 changes: 6 additions & 0 deletions pkg/cluster/gvk/gvk.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ var (
Group: "console.openshift.io",
Version: "v1", Kind: "OdhQuickStart",
}

OdhDashboardConfig = schema.GroupVersionKind{
Group: "opendatahub.io",
Version: "v1alpha",
Kind: "OdhDashboardConfig",
}
)
39 changes: 26 additions & 13 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ func UpdateFromLegacyVersion(cli client.Client, platform cluster.Platform, appNS
return nil
}

func getJPHOdhDocumentResources(namespace string, matchedName []string) []ResourceSpec {
metadataName := []string{"metadata", "name"}
return []ResourceSpec{
{
Gvk: gvk.OdhDocument,
Namespace: namespace,
Path: metadataName,
Values: matchedName,
},
}
}

func getDashboardWatsonResources(ns string) []ResourceSpec {
metadataName := []string{"metadata", "name"}
specAppName := []string{"spec", "appName"}
Expand Down Expand Up @@ -333,13 +345,19 @@ func CleanupExistingResource(ctx context.Context, cli client.Client, platform cl
// Remove deprecated opendatahub namespace(owned by kuberay)
multiErr = multierror.Append(multiErr, deleteDeprecatedNamespace(ctx, cli, "opendatahub"))

// Handling for dashboard Jupyterhub CR, see jira #443
JupyterhubApp := schema.GroupVersionKind{
Group: "dashboard.opendatahub.io",
Version: "v1",
Kind: "OdhApplication",
}
multiErr = multierror.Append(multiErr, removOdhApplicationsCR(ctx, cli, JupyterhubApp, "jupyterhub", dscApplicationsNamespace))
// Handling for dashboard OdhApplication Jupyterhub CR, see jira #443
multiErr = multierror.Append(multiErr, removOdhApplicationsCR(ctx, cli, gvk.OdhApplication, "jupyterhub", dscApplicationsNamespace))

// Handling for dashboard OdhDocument Jupyterhub CR, see jira #443 comments
odhDocJPH := getJPHOdhDocumentResources(
dscApplicationsNamespace,
[]string{
"jupyterhub-install-python-packages",
"jupyterhub-update-server-settings",
"jupyterhub-view-installed-packages",
"jupyterhub-use-s3-bucket-data",
})
multiErr = multierror.Append(multiErr, deleteResources(ctx, cli, &odhDocJPH))

// to take a reference
toDelete := getDashboardWatsonResources(dscApplicationsNamespace)
Expand Down Expand Up @@ -512,17 +530,12 @@ func removOdhApplicationsCR(ctx context.Context, cli client.Client, gvk schema.G
}

func unsetOwnerReference(cli client.Client, instanceName string, applicationNS string) error {
OdhDashboardConfig := schema.GroupVersionKind{
Group: "opendatahub.io",
Version: "v1alpha",
Kind: "OdhDashboardConfig",
}
crd := &apiextv1.CustomResourceDefinition{}
if err := cli.Get(context.TODO(), client.ObjectKey{Name: "odhdashboardconfigs.opendatahub.io"}, crd); err != nil {
return client.IgnoreNotFound(err)
}
odhObject := &unstructured.Unstructured{}
odhObject.SetGroupVersionKind(OdhDashboardConfig)
odhObject.SetGroupVersionKind(gvk.OdhDashboardConfig)
if err := cli.Get(context.TODO(), client.ObjectKey{
Namespace: applicationNS,
Name: instanceName,
Expand Down

0 comments on commit 6f90d70

Please sign in to comment.