-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Wait for mount
command to finish when mounting volume
#4305
Wait for mount
command to finish when mounting volume
#4305
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mheon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Still needs a test to verify we're correctly handling things. |
logrus.Debugf("Running mount command: %s %s", mountPath, strings.Join(mountArgs, " ")) | ||
if output, err := mountCmd.CombinedOutput(); err != nil { | ||
logrus.Debugf("Mount failed with %v", err) | ||
return errors.Wrapf(errors.Errorf(string(output)), "error mounting volume %s", v.Name()) |
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 think you should wrap the err, and then put the string(output) into the extra information.
return errors.Wrapf(err, "error mounting volume %s: %v", v.Name(),errors.Errorf(string(output)))
The error is just the exit code - the actual text of the error is
CombinedOutput(), which gets us STDERR for mount. It's a little verbose but
a lot better than "exit status 32" for a printed error.
…On Sun, Oct 20, 2019, 07:14 Daniel J Walsh ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In libpod/volume_internal_linux.go
<#4305 (comment)>:
> @@ -72,16 +72,10 @@ func (v *Volume) mount() error {
mountArgs = append(mountArgs, volDevice, v.config.MountPoint)
mountCmd := exec.Command(mountPath, mountArgs...)
- errPipe, err := mountCmd.StderrPipe()
- if err != nil {
- return errors.Wrapf(err, "error getting stderr pipe for mount")
- }
- if err := mountCmd.Start(); err != nil {
- out, err2 := ioutil.ReadAll(errPipe)
- if err2 != nil {
- return errors.Wrapf(err2, "error reading mount STDERR")
- }
- return errors.Wrapf(errors.New(string(out)), "error mounting volume %s", v.Name())
+ logrus.Debugf("Running mount command: %s %s", mountPath, strings.Join(mountArgs, " "))
+ if output, err := mountCmd.CombinedOutput(); err != nil {
+ logrus.Debugf("Mount failed with %v", err)
+ return errors.Wrapf(errors.Errorf(string(output)), "error mounting volume %s", v.Name())
I think you should wrap the err, and then put the string(output) into the
extra information.
return errors.Wrapf(err, , "error mounting volume %s: %v", v.Name(),errors.Errorf(string(output)))
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4305>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCALYYZHV35ATHX2XQDQPQ4PNANCNFSM4JCSAEGQ>
.
|
Well 32 is That way the caller could at least check for errors.Cause() on the error. |
did you add the test? is this ready for merge? |
Not yet. Will try and get to it today. |
5e1981e
to
7434fa7
Compare
Test added |
7434fa7
to
49c939f
Compare
☔ The latest upstream changes (presumably #4298) made this pull request unmergeable. Please resolve the merge conflicts. |
rebase and lets merge! |
49c939f
to
7799aba
Compare
Rebased |
command.Start() just starts the command. That catches some errors, but the nasty ones - bad options and similar - happen when the command runs. Use CombinedOutput() instead - it waits for the command to exit, and thus catches non-0 exit of the `mount` command (invalid options, for example). STDERR from the `mount` command is directly used, which isn't necessarily the best, but we can't really get much more info on what went wrong. Fixes containers#4303 Signed-off-by: Matthew Heon <[email protected]>
7799aba
to
3e891c1
Compare
CI should go green |
/hold |
/lgtm |
/hold cancel |
command.Start() just starts the command. That catches some errors, but the nasty ones - bad options and similar - happen when the command runs. Use CombinedOutput() instead - it waits for the command to exit, and thus catches non-0 exit of the
mount
command (invalid options, for example).STDERR from the
mount
command is directly used, which isn't necessarily the best, but we can't really get much more info on what went wrong.Fixes #4303