@@ -139,6 +139,7 @@ func (f *flistModule) cleanUnusedMounts() error {
139
139
}
140
140
141
141
if err := os .Remove (path ); err != nil {
142
+ log .Debug ().Msgf ("failed to remove path, trying to forcibly clean up : %+v" , path )
142
143
if err := f .forceUnmountAndRemove (path ); err != nil {
143
144
log .Error ().Err (err ).Msgf ("failed to clean mountpoint %s" , path )
144
145
}
@@ -149,7 +150,6 @@ func (f *flistModule) cleanUnusedMounts() error {
149
150
}
150
151
151
152
func (f * flistModule ) forceUnmountAndRemove (path string ) error {
152
- log .Debug ().Msgf ("trying to forcibly clean up : %+v" , path )
153
153
// Try normal unmount first
154
154
err := f .system .Unmount (path , 0 )
155
155
if err != nil {
@@ -158,14 +158,12 @@ func (f *flistModule) forceUnmountAndRemove(path string) error {
158
158
// Try lazy unmount (MNT_DETACH)
159
159
err = syscall .Unmount (path , syscall .MNT_DETACH )
160
160
if err != nil {
161
- log .Error ().Err (err ).Msgf ("lazy unmount also failed for %s" , path )
162
- return err
161
+ return errors .Wrapf (err , "lazy unmount also failed for %s" , path )
163
162
}
164
163
}
165
164
// Now try to remove the directory
166
165
if err := os .RemoveAll (path ); err != nil {
167
- log .Error ().Err (err ).Msgf ("failed to remove mountpoint %s" , path )
168
- return err
166
+ return errors .Wrapf (err , "failed to remove mountpoint %s" , path )
169
167
}
170
168
return nil
171
169
}
0 commit comments