Skip to content

Commit

Permalink
Wait until systemd unmount completed && explicitly set stop timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Sokolov committed Aug 13, 2024
1 parent 80dcfa4 commit 8b998ef
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 8b998ef

Please sign in to comment.