Skip to content

Commit 3055c28

Browse files
authored
try to umount, if timed out - attempt force umount (#13)
1 parent b2b2182 commit 3055c28

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

pkg/flex/mounter.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (m *Mounter) doMount(targetPath string) *Response {
4141
if err := mountCmd.Start(); err != nil {
4242
return Fail(fmt.Sprintf("Could not mount: %s", m.Target), err)
4343
}
44-
for _, interval := range []time.Duration{1, 2, 4} {
44+
for _, interval := range []time.Duration{1, 2, 4, 2, 1} {
4545
if isMountPoint(targetPath) {
4646
return Success("Mount completed!")
4747
}
@@ -110,16 +110,22 @@ func (m *Mounter) unmountAsLink() *Response {
110110
func (m *Mounter) osUmount() *Response {
111111
journal.Info("Calling osUmount command", "target", m.Target)
112112
if isMountPoint(m.Target) {
113-
cmd := exec.Command("umount", m.Target)
114-
journal.Debug("Calling umount command", "path", cmd.Path, "args", cmd.Args)
115-
if err := cmd.Start(); err != nil {
116-
return Fail("could not unmount", err)
113+
args := [][]string{
114+
{m.Target},
115+
{"--force", m.Target},
117116
}
118-
for _, interval := range []time.Duration{1, 2, 4} {
119-
if !isMountPoint(m.Target) {
120-
return Success("Unmount completed!")
117+
for _, commandArgs := range args {
118+
cmd := exec.Command("umount", commandArgs...)
119+
journal.Debug("Calling umount command", "path", cmd.Path, "args", cmd.Args)
120+
if err := cmd.Start(); err != nil {
121+
return Fail("could not unmount", err)
122+
}
123+
for _, interval := range []time.Duration{1, 2, 4, 2, 1} {
124+
if !isMountPoint(m.Target) {
125+
return Success("Unmount completed!")
126+
}
127+
time.Sleep(interval * time.Second)
121128
}
122-
time.Sleep(interval * time.Second)
123129
}
124130
return Fail(fmt.Sprintf("Could not umount due to timeout: %s", m.Target), nil)
125131
}

0 commit comments

Comments
 (0)