-
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
Fix error handling when trying to delete remote resources not present in Devfile #6659
Conversation
…t present in Devfile
… not present in Devfile Several Goroutines could potentially modify the same shared error variable, leading to weird behaviour, caught by the unit tests. Using errgroup allows simplifying goroutine error handling.
…s not present in Devfile Replace with a klog message, as the spinner does not add much value to the end user. Plus, it keeps displaying because we are regenerating the adapter which calls this function indefinitely.
✅ Deploy Preview for odo-docusaurus-preview canceled.
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@@ -693,40 +692,36 @@ func (a Adapter) deleteRemoteResources(objectsToRemove []unstructured.Unstructur | |||
resources = append(resources, fmt.Sprintf("%s/%s", u.GetKind(), u.GetName())) | |||
} | |||
|
|||
var err error | |||
spinner := log.Spinnerf("Deleting resources not present in the Devfile: %s", strings.Join(resources, ", ")) |
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 assume we're sacrificing the spinner message to be able to use errgroup and make sure we don't run into race conditions, yes?
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 could have used errgroup
with the spinner, as the spinner is started outside of the group and its status is updated after all goroutines have exited.
The problem is that odo
will continuously try to delete such resources that it couldn't delete (and display the spinner over and over again), which adds too much clutter to the terminal, IMO.
Also, I found the final status of the spinner to be a bit misleading by displaying ✓
, because it ignored PodMetrics
resources (in the example below), but it didn't delete them actually as it will try again to delete them :-).
Sample output with the spinner
$ odo dev
__
/ \__ Developing using the "my-node-app" Devfile
\__/ \ Namespace: default
/ \__/ odo version: v3.8.0
\__/
↪ Running on the cluster in Dev mode
• Waiting for Kubernetes resources ...
✓ Creating resource Pod/k8s-deploybydefault-true-and-not-referenced
✓ Creating resource Pod/k8s-deploybydefault-false-and-not-referenced
✓ Creating resource Pod/ocp-deploybydefault-true-and-not-referenced
✓ Creating resource Pod/k8s-deploybydefault-not-set-and-not-referenced
✓ Creating resource Pod/ocp-deploybydefault-false-and-not-referenced
✓ Creating resource Pod/ocp-deploybydefault-not-set-and-not-referenced
⚠ Pod is Pending
✓ Pod is Running
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-referenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [186ms]
✓ Syncing files into the container [101ms]
✓ Building your application in container (command: build) [3s]
• Executing the application (command: start-app) ...
- Forwarding from 127.0.0.1:20001 -> 3000
↪ Dev mode
Status:
Watching for changes in the current directory /home/asoro/work/tmp/5694-implement-autobuild-and-deploybydefault
Keyboard Commands:
[Ctrl+c] - Exit and delete resources from the cluster
[p] - Manually apply local changes to the application on the cluster
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-referenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [215ms]
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-referenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [839ms]
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-referenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [860ms]
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-r
eferenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [853ms]
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-r
eferenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [849ms]
✓ Deleting resources not present in the Devfile: PodMetrics/k8s-deploybydefault-false-and-not-referenced, PodMetrics/k8s-deploybydefault-not-set-and-not-referenced, PodMetrics/k8s-deploybydefault-true-and-not-r
eferenced, PodMetrics/ocp-deploybydefault-false-and-not-referenced, PodMetrics/ocp-deploybydefault-not-set-and-not-referenced, PodMetrics/ocp-deploybydefault-true-and-not-referenced [855ms]
...
This is why I thought it would make sense to klog
this instead.
To be addressed by #6545 /override Kubernetes-Integration-Tests/Kubernetes-Docs-Integration-Tests |
@rm3l: Overrode contexts on behalf of rm3l: Kubernetes-Integration-Tests/Kubernetes-Docs-Integration-Tests In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Flaky tests. /override windows-integration-test/Windows-test |
@rm3l: Overrode contexts on behalf of rm3l: windows-integration-test/Windows-test In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this:
/kind bug
What does this PR do / why we need it:
Stumbled upon this issue recently, and found a mistake in the
if
condition used to skip non-deletable resources (likePodMetrics
).We had this previously, which would actually never match:
After adding some unit tests, I also noticed that the way any error is detected might lead to a race condition: multiple Goroutines are trying to assign a shared error variable, and we are using that to determine the return value.
This is solved by using
errgroup
instead, which looks more appropriate to simplify goroutine error handling.Which issue(s) this PR fixes:
Fixes #6475
PR acceptance criteria:
Unit test
Integration test
Documentation
How to test changes / Special notes to the reviewer: