-
Notifications
You must be signed in to change notification settings - Fork 160
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
pkg/upgrade: remove watson-studio dashboard application #959
Conversation
Skipping CI for Draft Pull Request. |
/test all |
pkg/upgrade/upgrade.go
Outdated
@@ -254,6 +266,33 @@ func UpdateFromLegacyVersion(cli client.Client, platform deploy.Platform, appNS | |||
return nil | |||
} | |||
|
|||
func jobGetDashboardWatsonResources(ns string) []JobSpec { | |||
pathName := []string{"metadata", "name"} |
There was a problem hiding this comment.
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
pathName := []string{"metadata", "name"} | |
metaDataName := []string{"metadata", "name"} | |
specAppName := []string{"spec", "appName"} |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
have done test on the code, looks good for me |
pkg/upgrade/upgrade.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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?
pkg/upgrade/upgrade.go
Outdated
return errors.ErrorOrNil() | ||
} | ||
|
||
func deleteOneJob(ctx context.Context, c client.Client, job JobSpec) error { |
There was a problem hiding this comment.
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 was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
pkg/upgrade/upgrade.go
Outdated
@@ -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) |
There was a problem hiding this comment.
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 remove job
prefix here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, makes sense. Thanks!
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]>
/lgtm |
[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 |
23280e7
into
opendatahub-io:incubation
…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)
pkg/upgrade: remove watson-studio dashboard application (#959)
pkg/upgrade: remove watson-studio dashboard application (#959)
…-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]>
Remove deprecated dashboard resources, watson-studio
Description
Jira: https://issues.redhat.com/browse/RHOAIENG-4764
How Has This Been Tested?
Merge criteria: