Skip to content

Commit

Permalink
Merge pull request #135 from sm4ll-3gg/master
Browse files Browse the repository at this point in the history
[Bug] Wait until systemd unmount completed
  • Loading branch information
vitalif authored Aug 14, 2024
2 parents 80dcfa4 + 8b998ef commit 9e1eb85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/mounter/geesefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
}
// force & lazy unmount to cleanup possibly dead mountpoints
err = os.WriteFile(
unitPath+"/50-ExecStopPost.conf",
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\n"),
unitPath+"/50-StopProps.conf",
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\nTimeoutStopSec=20\n"),
0600,
)
if err != nil {
Expand Down
16 changes: 14 additions & 2 deletions pkg/mounter/mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,20 @@ func SystemdUnmount(volumeID string) (bool, error) {
if len(units) == 0 || units[0].ActiveState == "inactive" || units[0].ActiveState == "failed" {
return true, nil
}
_, err = conn.StopUnit(unitName, "replace", nil)
return true, err

resCh := make(chan string)
defer close(resCh)

_, err = conn.StopUnit(unitName, "replace", resCh)
if err != nil {
glog.Errorf("Failed to stop systemd unit (%s): %v", unitName, err)
return false, err
}

res := <-resCh // wait until is stopped
glog.Infof("Systemd unit is stopped with result (%s): %s", unitName, res)

return true, nil
}

func FuseUnmount(path string) error {
Expand Down

0 comments on commit 9e1eb85

Please sign in to comment.