Skip to content

Commit

Permalink
Cleanup mounts after stopping them using systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalif committed May 23, 2023
1 parent 3b38d54 commit 96818e5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/mounter/geesefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func (geesefs *geesefsMounter) MountDirect(target string, args []string) error {
return fuseMount(target, geesefsCmd, args)
}

type execCmd struct {
Path string
Args []string
UncleanIsFailure bool
}

func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
fullPath := fmt.Sprintf("%s:%s", geesefs.meta.BucketName, geesefs.meta.Prefix)
var args []string
Expand Down Expand Up @@ -147,6 +153,11 @@ func (geesefs *geesefsMounter) Mount(target, volumeID string) error {
Value: dbus.MakeVariant("GeeseFS mount for Kubernetes volume "+volumeID),
},
systemd.PropExecStart(args, false),
systemd.Property{
Name: "ExecStopPost",
// force & lazy unmount to cleanup possibly dead mountpoints
Value: dbus.MakeVariant([]execCmd{ execCmd{ "/bin/umount", []string{ "/bin/umount", "-f", "-l", target }, false } }),
},
systemd.Property{
Name: "Environment",
Value: dbus.MakeVariant([]string{ "AWS_ACCESS_KEY_ID="+geesefs.accessKeyID, "AWS_SECRET_ACCESS_KEY="+geesefs.secretAccessKey }),
Expand Down

0 comments on commit 96818e5

Please sign in to comment.