-
Notifications
You must be signed in to change notification settings - Fork 2.1k
context: improvements for handling non-existing contexts and errors #3868
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
Changes from all commits
566ea61
37b6dce
edaf16a
96e97de
685449f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| NAME DESCRIPTION DOCKER ENDPOINT ERROR | ||
| default Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| nosuchcontext * load context "nosuchcontext": context does n… |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| NAME DESCRIPTION DOCKER ENDPOINT | ||
| current * description of current https://someswarmserver.example.com | ||
| default Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| other description of other https://someswarmserver.example.com | ||
| unset description of unset https://someswarmserver.example.com | ||
| NAME DESCRIPTION DOCKER ENDPOINT ERROR | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's the title for the |
||
| current * description of current https://someswarmserver.example.com | ||
| default Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| other description of other https://someswarmserver.example.com | ||
| unset description of unset https://someswarmserver.example.com | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| NAME DESCRIPTION DOCKER ENDPOINT | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| remote my remote cluster ssh://someserver | ||
| NAME DESCRIPTION DOCKER ENDPOINT ERROR | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| remote my remote cluster ssh://someserver |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| NAME DESCRIPTION DOCKER ENDPOINT | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| test unix:///var/run/docker.sock | ||
| NAME DESCRIPTION DOCKER ENDPOINT ERROR | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| test unix:///var/run/docker.sock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| NAME DESCRIPTION DOCKER ENDPOINT | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| remote my remote cluster ssh://someserver | ||
| NAME DESCRIPTION DOCKER ENDPOINT ERROR | ||
| default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock | ||
| remote my remote cluster ssh://someserver |
Uh oh!
There was an error while loading. Please reload this page.
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.
As this is a new command, we can still change; do we think we should produce an error at all if the context wasn't found, or just "show the name of the context" (basically: this is what's configured to use, but you'll learn if it works once you use it)?
We could still opt for printing the error (on STDERR) as a warning, but make the command always return a zero exit code ("success").
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.
It seems like it should mimic existing behavior for other commands. e.g. for
inspect: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.
Hm... right; so
docker context inspectexpects a positional argument. It looks like there's a bug in thecompose-cliwrapper, as it hijacks thedocker contextsubcommands, and it looks like the usage information is incorrect;This is the output for compose-cli;
docker context inspect --help Display detailed information on one or more contexts Usage: docker context inspect [flags] Flags: -f, --format string Format the output using the given Go template -h, --help Help for inspectAnd the output for the actual docker cli;
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.
As to the
docker context show; that command was added in #3567. Basically its sole purpose is to show what context is configured, so that it can be used in prompts. An earlier PR (#2500) added it todocker infofor that purpose, butdocker context showis more convenient.As it (likely) will be used for prompts, the question is, should it always validate? Without validation, the value is still valid (it shows what's configured), but even if we check if the context is valid (can be found, and decoded), it may still be pointing to a host that's not reachable.