Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/upgrade: remove watson-studio dashboard application #959

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

ykaliuta
Copy link
Contributor

@ykaliuta ykaliuta commented Apr 8, 2024

Remove deprecated dashboard resources, watson-studio

Description

Jira: https://issues.redhat.com/browse/RHOAIENG-4764

How Has This Been Tested?

  • Install odh-2.9.0
  • Deploy odh-manifests/dashboard/overlays/apps/base/watson
  • Check odhapplications.dashboard.opendatahub.io, odhdocuments.dashboard.opendatahub.io and odhquickstarts.console.openshift.io in opendatahub namespace, watson objects exist
  • Deploy PR version
  • Restart operator pod
  • Observe that watson objects do not exist anymore

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link

openshift-ci bot commented Apr 8, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ykaliuta
Copy link
Contributor Author

ykaliuta commented Apr 8, 2024

/test all

@ykaliuta ykaliuta marked this pull request as ready for review April 9, 2024 12:25
@openshift-ci openshift-ci bot requested review from atheo89 and HumairAK April 9, 2024 12:25
@zdtsw zdtsw requested review from zdtsw and VaishnaviHire and removed request for HumairAK and atheo89 April 9, 2024 13:05
@@ -254,6 +266,33 @@ func UpdateFromLegacyVersion(cli client.Client, platform deploy.Platform, appNS
return nil
}

func jobGetDashboardWatsonResources(ns string) []JobSpec {
pathName := []string{"metadata", "name"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how you feel name it as

Suggested change
pathName := []string{"metadata", "name"}
metaDataName := []string{"metadata", "name"}
specAppName := []string{"spec", "appName"}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe not use variable but directly set it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how you feel name it as

Fine. Naming is a BIG question here, any suggestion is welcome!

Copy link
Contributor Author

@ykaliuta ykaliuta Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe not use variable but directly set it ?

it's repeated several times (except "metadata", "name" here, leftover from the previous version), I would prefer to keep them in variables since it's shorter. But no problem to change if you think it's better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then lets get the change for the variable names instead of hardcode path

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then lets get the change for the variable names instead of hardcode path
Updated. I just kept "metadata" lowercase as the field name.

@zdtsw
Copy link
Member

zdtsw commented Apr 9, 2024

have done test on the code, looks good for me

Comment on lines 49 to 56
type JobSpec struct {
Gvk schema.GroupVersionKind
Namespace string
// path to the field, like "metadata", "name"
Path []string
// set of values for the field to match object, any one matches
Values []string
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a JobSpec or ResourceSpec? It does not carry any job-specific traits (yet). Perhaps in #957 we could split ResourceSpec to carry what you defined here + matcher and expand on the JobSpec with retry and actual func doing the work. WDYT?

return errors.ErrorOrNil()
}

func deleteOneJob(ctx context.Context, c client.Client, job JobSpec) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if https://github.com/opendatahub-io/opendatahub-operator/pull/959/files#r1557861353 then this is deleteResource

There is name conflict here :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, but then maybe the original one could be renamed to deleteResourceWithRetry or sth like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Kept One in the name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Kept One in the name
Too fast, variable name probably better to rename as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, but then maybe the original one could be renamed to deleteResourceWithRetry or sth like that?

Pushed already :) Let's keep it then for further refactoring.

@@ -297,9 +336,63 @@ 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense. Thanks!

ykaliuta added 3 commits April 9, 2024 19:21
For the coming requirement to remove resources not just by their
names but a field inside of spec, abstract the existing
deleteDeprecatedResources/deleteDeprecatedServiceMonitors to take a
resource to delete description as

```
type ResourceSpec struct {
	Gvk       schema.GroupVersionKind
	Namespace string
	Path      []string
	Values    []string
}
```

TODO: This patch just adds new functionality without changing the
existing calls of deleteDeprecatedResources and
deleteDeprecatedServiceMonitors yet.

The function fetches UnstructuredList by gvk/namespace and uses
public unstructured.NestedString() to access the field by path.
It should work for ServiceMonitor, where ServiceMonitorList contains
list of the pointers, as well.

Ignore NoKindMatchError. CRD may not exist on fresh installation for
example.

Make a wrapper which takes an array of them for convenience and
avoid one indentation level and simplifies multierror wrapping a
bit.

It requires to have a library of GroupVersionKinds which is a future
work to make common for the whole project.

Signed-off-by: Yauheni Kaliuta <[email protected]>
schema.GroupVersionKind objects are used around the code, introduce
a common global place for it.

Add Odh GVKs to be used in the next patch.

Signed-off-by: Yauheni Kaliuta <[email protected]>
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]>
@VaishnaviHire
Copy link
Member

/lgtm

Copy link

openshift-ci bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: VaishnaviHire

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@VaishnaviHire VaishnaviHire merged commit 23280e7 into opendatahub-io:incubation Apr 10, 2024
3 of 8 checks passed
VaishnaviHire pushed a commit to VaishnaviHire/opendatahub-operator that referenced this pull request Apr 10, 2024
…io#959)

* pkg/upgrade: abstract resource deletion with Unstructured

For the coming requirement to remove resources not just by their
names but a field inside of spec, abstract the existing
deleteDeprecatedResources/deleteDeprecatedServiceMonitors to take a
resource to delete description as

```
type ResourceSpec struct {
	Gvk       schema.GroupVersionKind
	Namespace string
	Path      []string
	Values    []string
}
```

TODO: This patch just adds new functionality without changing the
existing calls of deleteDeprecatedResources and
deleteDeprecatedServiceMonitors yet.

The function fetches UnstructuredList by gvk/namespace and uses
public unstructured.NestedString() to access the field by path.
It should work for ServiceMonitor, where ServiceMonitorList contains
list of the pointers, as well.

Ignore NoKindMatchError. CRD may not exist on fresh installation for
example.

Make a wrapper which takes an array of them for convenience and
avoid one indentation level and simplifies multierror wrapping a
bit.

It requires to have a library of GroupVersionKinds which is a future
work to make common for the whole project.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* pkg/gvk: add package to store GroupVersionKind objects

schema.GroupVersionKind objects are used around the code, introduce
a common global place for it.

Add Odh GVKs to be used in the next patch.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* pkg/upgrade: remove watson-studio dashboard application

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]>

---------

Signed-off-by: Yauheni Kaliuta <[email protected]>
(cherry picked from commit 23280e7)
VaishnaviHire referenced this pull request in red-hat-data-services/rhods-operator Apr 10, 2024
pkg/upgrade: remove watson-studio dashboard application (#959)
VaishnaviHire referenced this pull request in red-hat-data-services/rhods-operator Apr 10, 2024
pkg/upgrade: remove watson-studio dashboard application (#959)
zdtsw referenced this pull request in zdtsw-forking/rhods-operator Apr 23, 2024
…-services#959)

* pkg/upgrade: abstract resource deletion with Unstructured

For the coming requirement to remove resources not just by their
names but a field inside of spec, abstract the existing
deleteDeprecatedResources/deleteDeprecatedServiceMonitors to take a
resource to delete description as

```
type ResourceSpec struct {
	Gvk       schema.GroupVersionKind
	Namespace string
	Path      []string
	Values    []string
}
```

TODO: This patch just adds new functionality without changing the
existing calls of deleteDeprecatedResources and
deleteDeprecatedServiceMonitors yet.

The function fetches UnstructuredList by gvk/namespace and uses
public unstructured.NestedString() to access the field by path.
It should work for ServiceMonitor, where ServiceMonitorList contains
list of the pointers, as well.

Ignore NoKindMatchError. CRD may not exist on fresh installation for
example.

Make a wrapper which takes an array of them for convenience and
avoid one indentation level and simplifies multierror wrapping a
bit.

It requires to have a library of GroupVersionKinds which is a future
work to make common for the whole project.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* pkg/gvk: add package to store GroupVersionKind objects

schema.GroupVersionKind objects are used around the code, introduce
a common global place for it.

Add Odh GVKs to be used in the next patch.

Signed-off-by: Yauheni Kaliuta <[email protected]>

* pkg/upgrade: remove watson-studio dashboard application

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]>

---------

Signed-off-by: Yauheni Kaliuta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants