-
Notifications
You must be signed in to change notification settings - Fork 243
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 deletes components running on podman #6418
odo delete component deletes components running on podman #6418
Conversation
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
f440dee
to
d861bdb
Compare
7a4d45a
to
b5ff0b5
Compare
488bf32
to
3d62435
Compare
Blocked by #6416 |
3d62435
to
1a1f455
Compare
d3266e4
to
b5112ac
Compare
// Kubernetes cluster access fails, return with a warning only | ||
err = clierrors.NewWarning(fmt.Sprintf("failed to get deployment %q", deploymentName), err) |
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.
We want to return a warning only if access to cluster fails, I think we should explicitly check for that error instead of returning a warning for all the errors.
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.
-
I would also like to, but I'm not sure we can find an exhaustive and definitive lit of such error(s).
-
As the function where it happens (ListClusterResourcesToDeleteFromDevfile) is a Devfile-related function, I would consider cluster information optional on the result, and never return an error when an error happens on the cluster, whatever the 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.
I would also like to, but I'm not sure we can find an exhaustive and definitive lit of such error(s).
What error is returned rn?
As the function where it happens (ListClusterResourcesToDeleteFromDevfile) is a Devfile-related function, I would consider cluster information optional on the result, and never return an error when an error happens on the cluster, whatever the error.
Yeah, I guess you're right about 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.
I would also like to, but I'm not sure we can find an exhaustive and definitive lit of such error(s).
What error is returned rn?
for the case I can think of, it is a "Forbidden" error
pkg/component/delete/delete_test.go
Outdated
podmanClient := podman.NewMockClient(ctrl) | ||
do := NewDeleteComponentClient(kubeClient, podmanClient, execClient) |
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.
nit:
Perhaps you can simply pass nil
since we are not going to use the podman client here.
pkg/component/delete/delete_test.go
Outdated
podmanClient := podman.NewMockClient(ctrl) | ||
execClient := exec.NewExecClient(kubeClient) | ||
do := NewDeleteComponentClient(kubeClient, execClient) | ||
do := NewDeleteComponentClient(kubeClient, podmanClient, execClient) |
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.
nit:
Perhaps you can simply pass nil
since we are not going to use the podman client here.
pkg/component/delete/delete_test.go
Outdated
podmanClient := podman.NewMockClient(ctrl) | ||
execClient := exec.NewExecClient(kubeClient) | ||
do := NewDeleteComponentClient(kubeClient, execClient) | ||
do := NewDeleteComponentClient(kubeClient, podmanClient, execClient) |
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.
nit:
Perhaps you can simply pass nil
since we are not going to use the podman client here.
} | ||
|
||
if !(hasClusterResources || hasPodmanResources) { | ||
log.Infof("No resource found for component %q in namespace %q nor in podman\n", 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.
log.Infof("No resource found for component %q in namespace %q nor in podman\n", componentName, namespace) | |
log.Infof("No resource found for component %q in namespace %q or in podman\n", 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.
might be nit:
I think it should only print "or in podman" if experimental mode is enabled. I would use messageWithPlatforms
function here.
if !feature.IsEnabled(ctx, feature.GenericRunOnFlag) { | ||
o.clientset.PodmanClient = nil | ||
} | ||
switch fcontext.GetRunOn(ctx, "") { | ||
case commonflags.RunOnCluster: | ||
o.clientset.PodmanClient = nil | ||
case commonflags.RunOnPodman: | ||
o.clientset.KubernetesClient = nil | ||
} | ||
|
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.
I would put this in Complete method instead of here. WDYT?
if err != nil { | ||
return err | ||
if o.clientset.KubernetesClient != nil { | ||
log.Info("Searching resources to delete, please wait...") |
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.
I'd move this message out of the if
loop, it seems more generic.
// Limit access to platforms if necessary | ||
if !feature.IsEnabled(ctx, feature.GenericRunOnFlag) { | ||
o.clientset.PodmanClient = nil | ||
} | ||
switch fcontext.GetRunOn(ctx, "") { | ||
case commonflags.RunOnCluster: | ||
o.clientset.PodmanClient = nil | ||
case commonflags.RunOnPodman: | ||
o.clientset.KubernetesClient = nil | ||
} | ||
|
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.
I think it should go on L79, because if o.name == ""
is satisfied, it will return early.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
/lgtm Thank you for working on this! |
What type of PR is this:
/kind feature
What does this PR do / why we need it:
odo delete component
support for podman when devfile is present(support for
--name
will be done in a separate PR)Which issue(s) this PR fixes:
Fixes partially #6296
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: