Skip to content

Commit

Permalink
Improve error handling, do not remove CollectMode (fix #101)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed Mar 13, 2024
1 parent 11d8b4b commit 80c1171
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pkg/mounter/geesefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,21 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
conn.ResetFailedUnit(unitName)
}
}
err = os.MkdirAll("/run/systemd/system/" + unitName + ".d", 0755)
if err == nil {
// force & lazy unmount to cleanup possibly dead mountpoints
err = os.WriteFile(
"/run/systemd/system/" + unitName + ".d/50-ExecStopPost.conf",
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\n"),
0600,
)
if err == nil {
_, err = conn.StartTransientUnit(unitName, "replace", newProps[0:len(newProps)-1], nil)
}
unitPath := "/run/systemd/system/" + unitName + ".d"
err = os.MkdirAll(unitPath, 0755)
if err != nil {
return fmt.Errorf("Error creating directory %s: %v", unitPath, err)
}
// force & lazy unmount to cleanup possibly dead mountpoints
err = os.WriteFile(
unitPath+"/50-ExecStopPost.conf",
[]byte("[Service]\nExecStopPost=/bin/umount -f -l "+target+"\n"),
0600,
)
if err != nil {
return fmt.Errorf("Error writing %v/50-ExecStopPost.conf: %v", unitPath, err)
}
_, err = conn.StartTransientUnit(unitName, "replace", newProps, nil)
if err != nil {
return fmt.Errorf("Error starting systemd unit %s on host: %v", unitName, err)
}
Expand Down

0 comments on commit 80c1171

Please sign in to comment.