-
Notifications
You must be signed in to change notification settings - Fork 244
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
odo delete component - show warning that something was not deleted #5598
odo delete component - show warning that something was not deleted #5598
Conversation
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
pkg/odo/cli/delete/component.go
Outdated
var remainingResources []unstructured.Unstructured | ||
k8sResources, _ := o.clientset.DeleteClient.ListResourcesToDelete(componentName, namespace) | ||
// get resources present in k8sResources(present on the cluster) but not in devfileResources(not present in the devfile) | ||
if len(k8sResources) != 0 { |
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 this check redundant? I wonder so because we are already returning when if len(devfileResources) == 0
, and I think it's safe to assume that if that condition is not satisfied, this condition will never be satisfied. WDYT?
pkg/odo/cli/delete/component.go
Outdated
for _, k8sresource := range k8sResources { | ||
var present bool | ||
for _, dresource := range devfileResources { | ||
// skip the component's endpoints resource |
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.
// skip the component's endpoints resource | |
// skip the component's endpoints resource |
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.
Also, there's more happening below than just skipping an endpoint resource. Can you summarize that briefly in the code comment?
pkg/odo/cli/delete/component.go
Outdated
for _, dresource := range devfileResources { | ||
// skip the component's endpoints resource | ||
if reflect.DeepEqual(dresource, k8sresource) || (k8sresource.GetKind() == "Endpoints" && strings.Contains(k8sresource.GetName(), componentName)) { | ||
present = true |
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.
Should we add a break
statement here so that it doesn't check for the remaining resources in the slice?
pkg/odo/cli/delete/component.go
Outdated
log.Infof("No resource found for component %q in namespace %q\n", componentName, namespace) | ||
return nil | ||
} | ||
|
||
var remainingResources []unstructured.Unstructured | ||
k8sResources, _ := o.clientset.DeleteClient.ListResourcesToDelete(componentName, namespace) |
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.
This is not a part of this PR, but, IMO, this method should have been named ListKubernetesResourceToDelete
ListClusterResourceToDelete
instead. The other method in this interface, ListResourcesToDeleteFromDevfile
, is clear from its name itself as to which resources it will delete.
for _, resource := range remainingResources { | ||
fmt.Printf("\t- %s: %s\n", resource.GetKind(), resource.GetName()) | ||
} |
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.
Can we use the tabwriter here instead? It takes care of formatting. We have used it in the odo code in the past.
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.
@cdrage mentioned that he will be modifying the UX for odo. I'd rather leave this and the delete UX in general, in his good hands.
989c4c3
to
2d27360
Compare
Please update the mock so the unit tests and validation pass |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: feloy 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 |
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
2d27360
to
d414924
Compare
Kudos, SonarCloud Quality Gate passed!
|
/lgtm |
…edhat-developer#5598) * Warn about missing resources Signed-off-by: Parthvi Vala <pvala@redhat.com> * Dharmit's review Signed-off-by: Parthvi Vala <pvala@redhat.com> * Add unit tests and some other changes
Signed-off-by: Parthvi Vala pvala@redhat.com
What type of PR is this:
/kind feature
What does this PR do / why we need it:
This PR adds information about not deleted component resources because devfile.yaml was changed.
Which issue(s) this PR fixes:
Fixes #5555
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer:
mkdir /tmp/101; cd /tmp/101
cp $ODOPATH/tests/examples/source/devfiles/nodejs/devfile-deploy-with-multiple-resources.yaml devfile.yaml
cp -r $ODOPATH/tests/examples/source/nodejs/* .
export PODMAN_CMD=echo
odo deploy
odo dev
my-cs
service name tomy-changed-cs
in devfile.yamlodo delete component
Output will be similar to: