Comments (7)
Oh! I think I meant to @
@Benehiko, and for some reason pinged @krissetto 🙈 - well, both of you are here now, so all good 😂
from cli.
cc @Benehiko
from cli.
Good point from @tonistiigi here – #4888 (comment).
A more holistic approach would be to always set up signal handling in the CLI, and use it to cancel the command's context, and just migrate most places in the codebase that are setting up their own signal handling to instead handle context cancellation – funny that we do this for plugins but not for anything else.
from cli.
Good catch. I agree with always setting up a signal handler in the CLI and cancelling with the context, but i'm not sure how many changes it'd require in the codebase ATM to pass the context everywhere it might be needed.
I think what confused me was this part of the signal.NotifyContext
docs:
The stop function unregisters the signal behavior, which, like signal.Reset, may restore the default behavior for a given signal. For example, the default behavior of a Go program receiving os.Interrupt is to exit. Calling NotifyContext(parent, os.Interrupt) will change the behavior to cancel the returned context.
I thought that once a signal got consumed, the original behavior would be restored (so the default signal handling behavior of the application).
That said, I think this specific panic is only related to the test, as the code itself doesn't explicitly close any channels (the result
chan in this case) in a way that could result in this issue.
Particularly this part at lines 205-210 of utils_test.go
might be at fault
result := make(chan promptResult, 1)
defer close(result)
go func() {
r, err := command.PromptForConfirmation(ctx, promptReader, promptOut, "")
result <- promptResult{r, err}
}()
from cli.
Ah, yes, I saw that comment, and wanted to ask @krissetto about it as well.
A more holistic approach would be to always set up signal handling in the CLI, and use it to cancel the command's context,
Sounds like a sensible approach yes (or at least, that's my first response; contexts are always fun)
from cli.
Good point from @tonistiigi here – #4888 (comment).
A more holistic approach would be to always set up signal handling in the CLI, and use it to cancel the command's context, and just migrate most places in the codebase that are setting up their own signal handling to instead handle context cancellation – funny that we do this for plugins but not for anything else.
I think this can only work once we have wired up context.Context
. There are some PRs I've already made for this to support otel
tracing. So I would think we could move the signal termination out from the prompt function to the main function running the cobra command once these PRs are merged.
from cli.
Looking at this error, I think the timeout might be too little for some machines. I've not been able to reproduce this flake locally on my laptop so the flake might be dependent on the machine running it.
I'm guessing the timeout for the context is reached (100 milliseconds) and then the test is ended with t.Fatal()
in the process of this, the function executing the test exits closing the result
channel. However, the goroutine is still running waiting for a result from the prompt function. The prompt does return eventually and tries to send on the closed result
channel causing the program to panic.
This is a tricky one since there is no way to guarantee that closing the reader will exit the prompt in a given time frame since this would be dependent on the OS and machine hardware. I could prevent the panic by not closing the channels inside the test and leaving it up to the garbage collector and hope that an increase to say 500ms or 1 second timeout is enough for most cases.
from cli.
Related Issues (20)
- env_file not working anymore in 'docker stack deploy' HOT 5
- cannot `docker stop` (SIGINT?) a tail -f /dev/null command
- Docker build is not recognising the `-e` flag for the echo command HOT 2
- When creating or starting a container, there is a prompt indicating that the container has failed to start. HOT 2
- "OTEL_RESOURCE_ATTRIBUTES" in .env is ignored when using docker compose HOT 2
- Docker push for single arch not work with containerd storage HOT 2
- Account for aliases when running plugin hooks
- volume-subpath does not work for docker service HOT 1
- Inconsistent JSON output in `docker context ls --format json` HOT 3
- Slack link in `CONTRIBUTING.md` is invalid HOT 1
- Docker fails to provide DNS/name/alias to containers in a overlay network when is created with IPv6 HOT 2
- Could new aliaess be added to mirror existing and which start with 'doc' for example, so can see the docker aliases that are defined?
- Docker service logs are not returned in chronological order HOT 1
- Docker push missing visibility setting HOT 1
- Warning: Kernel Does Not Support cpuset or Cgroup Not Mounted
- docker rmi <image:tag> deletes both amd64 and arm64 builds on Apple Silicon HOT 1
- sysctl issues after upgrade from 25.0.4 to 26.0.0 HOT 1
- Proposal: Adding `docker init` Command to Docker CLI HOT 1
- API from container seem can not get response HOT 3
- build: don't hardcode classic builder for windows daemons HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.