@@ -15,6 +15,7 @@ import (
15
15
"github.com/IBM/ibm-object-csi-driver/pkg/constants"
16
16
"github.com/mitchellh/go-ps"
17
17
"k8s.io/klog/v2"
18
+ k8sMountUtils "k8s.io/mount-utils"
18
19
)
19
20
20
21
var unmount = syscall .Unmount
@@ -32,16 +33,19 @@ type MounterOptsUtils struct {
32
33
33
34
func (su * MounterOptsUtils ) FuseMount (path string , comm string , args []string ) error {
34
35
klog .Info ("-FuseMount-" )
35
- klog .Infof ("FuseMount params:\n \t path: <%s>\n \t command: <%s>\n \t args: <%s >" , path , comm , args )
36
+ klog .Infof ("FuseMount params:\n \t path: <%s>\n \t command: <%s>\n \t args: <%v >" , path , comm , args )
36
37
out , err := command (comm , args ... ).CombinedOutput ()
37
38
if err != nil {
39
+ klog .Warningf ("FuseMount: mount command failed: mounter=%s, args=%v, error=%v, output=%s" , comm , args , err , string (out ))
40
+ klog .Infof ("FuseMount: checking if path already exists and is a mountpoint: path=%s" , path )
38
41
if mounted , err1 := isMountpoint (path ); err1 == nil && mounted { // check if bucket already got mounted
39
42
klog .Infof ("bucket is already mounted using '%s' mounter" , comm )
40
43
return nil
41
44
}
42
- klog .Errorf ("FuseMount: command execution failed: <%s> \n args: <%s> \n error: <%v> \n output: <%v> " , comm , args , err , string ( out ) )
45
+ klog .Errorf ("FuseMount: path is not mountpoint, mount failed: path=%s " , path )
43
46
return fmt .Errorf ("'%s' mount failed: <%v>" , comm , string (out ))
44
47
}
48
+ klog .Infof ("mount command succeeded: mounter=%s, output=%s" , comm , string (out ))
45
49
if err := waitForMount (path , 10 * time .Second ); err != nil {
46
50
return err
47
51
}
@@ -126,20 +130,21 @@ func isMountpoint(pathname string) (bool, error) {
126
130
127
131
func waitForMount (path string , timeout time.Duration ) error {
128
132
var elapsed time.Duration
133
+ attempt := 1
129
134
for {
130
- out , err := exec .Command ("mountpoint" , path ).CombinedOutput ()
131
- outStr := strings .TrimSpace (string (out ))
132
- if err == nil && strings .HasSuffix (outStr , "is a mountpoint" ) {
133
- klog .Infof ("Path is a mountpoint: pathname - %s" , path )
135
+ isMount , err := k8sMountUtils .New ("" ).IsMountPoint (path )
136
+ if err == nil && isMount {
137
+ klog .Infof ("Path is a mountpoint: pathname: %s" , path )
134
138
return nil
135
139
}
136
140
137
- klog .Infof ("Mountpoint check in progress: path=%s, output=%s , err=%v" , path , outStr , err )
141
+ klog .Infof ("Mountpoint check in progress: attempt=%d, path=%s, isMount=%v , err=%v" , attempt , path , isMount , err )
138
142
time .Sleep (constants .Interval )
139
- elapsed = elapsed + constants .Interval
143
+ elapsed += constants .Interval
140
144
if elapsed >= timeout {
141
- return fmt .Errorf ("timeout waiting for mount: last check output: %s " , outStr )
145
+ return fmt .Errorf ("timeout waiting for mount. Last check response: isMount=%v, err=%v " , isMount , err )
142
146
}
147
+ attempt ++
143
148
}
144
149
}
145
150
0 commit comments