Skip to content

Commit 7947b83

Browse files
committed
log debug message if failed to remove
1 parent af77b7c commit 7947b83

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pkg/flist/cleanup.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ func (f *flistModule) cleanUnusedMounts() error {
139139
}
140140

141141
if err := os.Remove(path); err != nil {
142+
log.Debug().Msgf("failed to remove path, trying to forcibly clean up : %+v", path)
142143
if err := f.forceUnmountAndRemove(path); err != nil {
143144
log.Error().Err(err).Msgf("failed to clean mountpoint %s", path)
144145
}
@@ -149,7 +150,6 @@ func (f *flistModule) cleanUnusedMounts() error {
149150
}
150151

151152
func (f *flistModule) forceUnmountAndRemove(path string) error {
152-
log.Debug().Msgf("trying to forcibly clean up : %+v", path)
153153
// Try normal unmount first
154154
err := f.system.Unmount(path, 0)
155155
if err != nil {
@@ -158,14 +158,12 @@ func (f *flistModule) forceUnmountAndRemove(path string) error {
158158
// Try lazy unmount (MNT_DETACH)
159159
err = syscall.Unmount(path, syscall.MNT_DETACH)
160160
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)
163162
}
164163
}
165164
// Now try to remove the directory
166165
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)
169167
}
170168
return nil
171169
}

0 commit comments

Comments
 (0)