|
4 | 4 | package utils |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "bytes" |
7 | 8 | "errors" |
8 | 9 | "fmt" |
9 | 10 | "os" |
@@ -31,18 +32,30 @@ type MounterOptsUtils struct { |
31 | 32 | } |
32 | 33 |
|
33 | 34 | func (su *MounterOptsUtils) FuseMount(path string, comm string, args []string) error { |
34 | | - klog.Info("-FuseMount-") |
35 | | - klog.Infof("FuseMount params:\n\tpath: <%s>\n\tcommand: <%s>\n\targs: <%s>", path, comm, args) |
36 | | - out, err := command(comm, args...).CombinedOutput() |
| 35 | + klog.Infof("FuseMount params:\n\tpath: <%s>\n\tcommand: <%s>\n\targs: <%v>", path, comm, args) |
| 36 | + cmd := command(comm, args...) |
| 37 | + |
| 38 | + var outb, errb bytes.Buffer |
| 39 | + cmd.Stdout = &outb |
| 40 | + cmd.Stderr = &errb |
| 41 | + |
| 42 | + err := cmd.Start() |
| 43 | + if err != nil { |
| 44 | + klog.Errorf("FuseMount: command start failed: <%s>\nargs: <%v>\nerror: <%v>", comm, args, err) |
| 45 | + return fmt.Errorf("FuseMount: command start failed: <%s>\nerror: <%v>", comm, err) |
| 46 | + } |
| 47 | + err = cmd.Wait() |
37 | 48 | if err != nil { |
38 | 49 | if mounted, err1 := isMountpoint(path); err1 == nil && mounted { // check if bucket already got mounted |
39 | 50 | klog.Infof("bucket is already mounted using '%s' mounter", comm) |
40 | 51 | return nil |
41 | 52 | } |
42 | | - klog.Errorf("FuseMount: command execution failed: <%s>\nargs: <%s>\nerror: <%v>\noutput: <%v>", comm, args, err, string(out)) |
43 | | - return fmt.Errorf("'%s' mount failed: <%v>", comm, string(out)) |
| 53 | + klog.Errorf("FuseMount: command wait failed: <%s>\nargs: <%v>\nerr: <%v>\nstderr: <%s>\nstdout: <%s>", comm, args, err, errb.String(), outb.String()) |
| 54 | + return fmt.Errorf("'%s' mount failed: %v (stderr: %s)", comm, err, errb.String()) |
44 | 55 | } |
| 56 | + klog.Infof("mount command succeeded: mounter=%s, output=%s", comm, outb.String()) |
45 | 57 | if err := waitForMount(path, 10*time.Second); err != nil { |
| 58 | + klog.Errorf("mount succeeded but waiting for mountpoint failed: %v", err) |
46 | 59 | return err |
47 | 60 | } |
48 | 61 | klog.Infof("bucket mounted successfully using '%s' mounter", comm) |
|
0 commit comments