Skip to content

Commit 9e1eb85

Browse files
authored
Merge pull request #135 from sm4ll-3gg/master
[Bug] Wait until systemd unmount completed
2 parents 80dcfa4 + 8b998ef commit 9e1eb85

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pkg/mounter/geesefs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
207207
}
208208
// force & lazy unmount to cleanup possibly dead mountpoints
209209
err = os.WriteFile(
210-
unitPath+"/50-ExecStopPost.conf",
211-
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\n"),
210+
unitPath+"/50-StopProps.conf",
211+
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\nTimeoutStopSec=20\n"),
212212
0600,
213213
)
214214
if err != nil {

pkg/mounter/mounter.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,20 @@ func SystemdUnmount(volumeID string) (bool, error) {
9696
if len(units) == 0 || units[0].ActiveState == "inactive" || units[0].ActiveState == "failed" {
9797
return true, nil
9898
}
99-
_, err = conn.StopUnit(unitName, "replace", nil)
100-
return true, err
99+
100+
resCh := make(chan string)
101+
defer close(resCh)
102+
103+
_, err = conn.StopUnit(unitName, "replace", resCh)
104+
if err != nil {
105+
glog.Errorf("Failed to stop systemd unit (%s): %v", unitName, err)
106+
return false, err
107+
}
108+
109+
res := <-resCh // wait until is stopped
110+
glog.Infof("Systemd unit is stopped with result (%s): %s", unitName, res)
111+
112+
return true, nil
101113
}
102114

103115
func FuseUnmount(path string) error {

0 commit comments

Comments
 (0)