Skip to content

cmd/docker: do not print error status on exec/run - #5854

Merged
vvoland merged 1 commit into
docker:masterfrom
Benehiko:fix-exec-msg
Feb 21, 2025
Merged

cmd/docker: do not print error status on exec/run#5854
vvoland merged 1 commit into
docker:masterfrom
Benehiko:fix-exec-msg

Conversation

@Benehiko

@BenehikoBenehiko commented Feb 21, 2025

Copy link
Copy Markdown
Member

- What I did
Do not print to std.Err when using docker exec.

- How I did it
Be explicit on printing the Cause/Status from StatusError instead of a fallback to a generic error message.

- How to verify it

- Human readable description for the release notes

Fix unintentionally printing exit status to stderr when `docker exec/run` returns a non-zero status

- A picture of a cute animal (not mandatory but encouraged)

@Benehiko
Benehikoforce-pushed the fix-exec-msg branch 4 times, most recently from 2ac3ab0 to bfe64dfCompareFebruary 21, 2025 10:46
@codecov-commenter

codecov-commenter commented Feb 21, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 59.27%. Comparing base (eb48cad) to head (0cff340).
Report is 17 commits behind head on master.

❌ Your patch status has failed because the patch coverage (20.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@ Coverage Diff @@## master #5854 +/- ##
==========================================
+ Coverage 58.89% 59.27% +0.37% 
==========================================
Files 350 353 +3 Lines 29682 29694 +12 ==========================================
+ Hits 17482 17601 +119 + Misses 11218 11113 -105 + Partials 982 980 -2 

@thaJeztahthaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

assert.Equal(t, c.ProcessState.ExitCode(), 7)
assert.Check(t, is.Contains(d.String(), "exit status 7"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess if we want to be strict in our tests, we could consider checking for the error message to be empty (with a comment);

assert.Check(t, is.Equal(err.Error(), ""), "should not print our own error message, as the container's output is the error message")

Not urgent for how, but something we could consider

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp; meant checking the d.String() for what we expect it to output (for that we could add a echo "something failed" to the container's command.

(but again, probably fine to look at in a follow up)

@vvolandvvoland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vvoland

Copy link
Copy Markdown
Collaborator

Note: This also fixes run so the title/changelog should be adjusted

@BenehikoBenehiko changed the title cmd/docker: do not print error status on execcmd/docker: do not print error status on exec/runFeb 21, 2025
@thaJeztah

Copy link
Copy Markdown
Member

Heh; probably best to update the commit message, not just the PR title 😂 😇

Screenshot 2025-02-21 at 12 54 28

Co-authored-by: Fabio Pugliese Ornellas <fabio.ornellas@gmail.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
@Benehiko

Copy link
Copy Markdown
MemberAuthor

Heh; probably best to update the commit message, not just the PR title 😂 😇
Screenshot 2025-02-21 at 12 54 28

too many places to update 🙈
PR title, changelog, commit title

@thaJeztahthaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

yeah, bit of a hassle always; sometimes help finding back changes in git history though!

@vvoland
vvoland merged commit 77a8a8c into docker:masterFeb 21, 2025
@felixfontein

Copy link
Copy Markdown

Is it possible to get a 28.0.1 release soon with this fix included?

@vvoland

Copy link
Copy Markdown
Collaborator

Yes, we will be having a patch release this week (Wednesday is the initial plan).

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DinD commands exiting with non-zero return code add "exit status" to stderr text

5 participants

@Benehiko@codecov-commenter@vvoland@thaJeztah@felixfontein