-
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
Deleting a component also unlinks it from components it might be linked to #2447
Deleting a component also unlinks it from components it might be linked to #2447
Conversation
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kadel 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 |
@amitkrout @kadel do you think I should add integration tests here? The scenario I can think of is same as what I've described in the "How to test changes" section of this PR. @amitkrout if yes, which file do you recommend I add it to? |
yes that would be great!
I would categorize it as link test. |
@mik-dass Thanks for the tip! It makes sense. But I'll need some help. Can you see if you can help me? Here's the $ git diff
diff --git a/pkg/odo/cli/component/delete.go b/pkg/odo/cli/component/delete.go
index 932df0f3e..9a0fdadae 100644
--- a/pkg/odo/cli/component/delete.go
+++ b/pkg/odo/cli/component/delete.go
@@ -99,13 +99,18 @@ func (do *DeleteOptions) Run() (err error) {
componentSecrets := component.UnlinkComponents(parentComponent, compoList)
for component, secret := range componentSecrets {
+ spinner := log.NewStatus(log.GetStdout())
+ defer spinner.End(true)
for _, secretName := range secret {
+ spinner.Start(fmt.Sprintf("Unlinking component %q from component %q for secret %q\n", parentComponent.Name, component, secretName), false)
err = do.Client.UnlinkSecret(secretName, component, do.Context.Application)
if err != nil {
+ log.Errorf("Unlinking failed")
return err
}
- log.Successf("Unlinked component %q from component %q for secret %q", parentComponent.Name, component, secretName)
+ log.Successf("Unlink successful")
}
+ spinner.End(true)
}
err = component.Delete(do.Client, do.componentName, do.Application)
if err != nil { And here's the output which is clearly messed up! odo delete -f
◐ Unlinking component "backend" from component "frontend" for secret "backend-app-8778"
◓ Unlinking component "backend" from component "frontend" for secret "backend-app-8778"
◑ Unlinking component "backend" from component "frontend" for secret "backend-app-8778"
✓ Unlink successful
✓ Unlinking component "backend" from component "frontend" for secret "backend-app-8778"
[614ms]
◐ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◓ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◑ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◒ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◐ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◓ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
◑ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
✓ Unlink successful
✓ Unlinking component "backend" from component "frontend" for secret "backend-app-8080"
[2s]
◐ Unlinking component "backend" from component "node" for secret "backend-app-8080"
◓ Unlinking component "backend" from component "node" for secret "backend-app-8080"
◑ Unlinking component "backend" from component "node" for secret "backend-app-8080"
◒ Unlinking component "backend" from component "node" for secret "backend-app-8080"
✓ Unlink successful
✓ Unlinking component "backend" from component "node" for secret "backend-app-8080"
[921ms]
◐ Unlinking component "backend" from component "node" for secret "backend-app-8778"
◓ Unlinking component "backend" from component "node" for secret "backend-app-8778"
◑ Unlinking component "backend" from component "node" for secret "backend-app-8778"
✓ Unlink successful
✓ Unlinking component "backend" from component "node" for secret "backend-app-8778"
[2s]
✓ Deleting component backend [920ms]
✓ Component backend from application app has been deleted Do you think you can suggest where I can improve here? |
Think I managed to have a sane output: odo delete -f
✓ Unlinking components [614ms]
✓ Unlinking component "backend" from component "node" for secret "backend-app-8080"
✓ Unlinking component "backend" from component "node" for secret "backend-app-8778"
✓ Deleting component backend [1s]
✓ Component backend from application app has been deleted with this $ git diff
diff --git a/pkg/odo/cli/component/delete.go b/pkg/odo/cli/component/delete.go
index 932df0f3e..617d98c92 100644
--- a/pkg/odo/cli/component/delete.go
+++ b/pkg/odo/cli/component/delete.go
@@ -99,12 +99,19 @@ func (do *DeleteOptions) Run() (err error) {
componentSecrets := component.UnlinkComponents(parentComponent, compoList)
for component, secret := range componentSecrets {
+ spinner := log.Spinner("Unlinking components")
for _, secretName := range secret {
+
+ defer spinner.End(false)
+
err = do.Client.UnlinkSecret(secretName, component, do.Context.Application)
if err != nil {
+ log.Errorf("Unlinking failed")
return err
}
- log.Successf("Unlinked component %q from component %q for secret %q", parentComponent.Name, component, secretName)
+
+ spinner.End(true)
+ log.Successf(fmt.Sprintf("Unlinking component %q from component %q for secret %q\n", parentComponent.Name, component, secretName))
}
}
err = component.Delete(do.Client, do.componentName, do.Application) |
@dharmit The new output looks good to me 👍 |
Done. PR's ready for another round of review @kadel @mik-dass @cdrage. |
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.
/lgtm
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
What kind of PR is this?
/kind bug
What does does this PR do / why we need it:
This PR unlinks a component requested for deletion from all the components it might be linked to in the OpenShift cluster
Which issue(s) this PR fixes:
Fixes #2355
How to test changes / Special notes to the reviewer:
odo create nodejs node
odo create java java
node
's context directory doodo link java --port 8080
java
's context directory doodo delete -f
node
's context directory doodo delete -f