-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Fail when there is an error executing an inspect template. #17284
Conversation
@calavera needs rebase |
e3b371b
to
95732e0
Compare
Rebased |
status = 1 | ||
continue | ||
break |
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.
why break? it used to continue to the next argument to 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.
is that the fix?
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.
because there is something very wrong when we cannot decode an api response and we should not continue with the next arguments.
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.
The previous behavior explained like a movie:
- Client: hey, can I have this container's info?
- API: sure, here you have some gibberish that might not even be a json payload
- Client: cool, can I have this other container's info?
The new behavior goes like this:
- Client: hey, can I have this container's info?
- API: sure, here you have some gibberish that might not even be a json payload
- Client: what's wrong with you API?? abort!
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.
😆
After further investigation, it looks like this fix also solves #17026:
|
at one point I thought @shishir-a412ed had a fix for this that just tried using the current path, and then if that failed it tried again using the raw - but didn't output anything until the end. Would be easier? |
that's exactly what this patch does. Look at the |
yea, its just I think he did it w/o a new func and I remember it being just a few more lines added - but perhaps I'm remembering incorrectly. |
No, he didn't do any of that, he's PR modified the the api returned types and removed the raw decoding. |
the latest did yea, but I think an older version didn’t do all of that.
|
- Do not execute the template directly in the cli outout, go is not atomic in this operation and can send bytes before failing the execution. - Fail after evaluating a raw interface if the typed execution also failed, assuming there is a template parsing error. Signed-off-by: David Calavera <david.calavera@gmail.com>
95732e0
to
3b9c138
Compare
@@ -101,42 +100,45 @@ func (cli *DockerCli) CmdInspect(args ...string) error { | |||
} else { | |||
rdr := bytes.NewReader(obj) | |||
dec := json.NewDecoder(rdr) | |||
buf := bytes.NewBufferString("") |
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.
buf := new(bytes.Buffer)
is more idiomatic but dont update just for this
LGTM |
1 similar comment
LGTM |
Fail when there is an error executing an inspect template.
Do we want to do the same for
|
@phemmer I'd say yes. We already handle ps like that and I think it's a good UX behavior, partial outputs are not very friendly. |
in this operation and can send bytes before failing the execution.
failed, assuming there is a template parsing error.
Closes #15566
Closes #17026
Signed-off-by: David Calavera david.calavera@gmail.com