Skip to content

Commit

Permalink
fix umount hang and ignore fuse fd if get fd error
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <[email protected]>
  • Loading branch information
zwwhdls committed Sep 24, 2024
1 parent 1fd19d3 commit 7ce0dc7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions pkg/controller/mountinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (ti *targetItem) check(ctx context.Context, mounted bool) {

if err.Error() == "function timeout" {
ti.status = targetStatusCorrupt
return
}
corrupted := k8sMount.IsCorruptedMnt(err)
if corrupted {
Expand Down
10 changes: 8 additions & 2 deletions pkg/controller/pod_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ func (p *PodDriver) podDeletedHandler(ctx context.Context, pod *corev1.Pod) (Res

if len(existTargets) == 0 {
// do not need to create new one, umount
util.UmountPath(ctx, sourcePath)
_ = util.DoWithTimeout(ctx, defaultCheckoutTimeout, func() error {
util.UmountPath(ctx, sourcePath)
return nil
})
// clean mount point
err = util.DoWithTimeout(ctx, defaultCheckoutTimeout, func() error {
log.Info("Clean mount point", "mountPath", sourcePath)
Expand Down Expand Up @@ -736,7 +739,10 @@ func (p *PodDriver) umountTargetUntilRemain(ctx context.Context, basemi *mountIt
return nil
}

util.UmountPath(subCtx, target)
_ = util.DoWithTimeout(ctx, defaultCheckoutTimeout, func() error {
util.UmountPath(subCtx, target)
return nil
})
}
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/fuse/passfd/passfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ func (fs *Fds) CloseFd(podHashVal string) {

func (fs *Fds) parseFuse(ctx context.Context, podHashVal, fusePath string) {
fuseFd, fuseSetting := GetFuseFd(fusePath, false)
if fuseFd < 0 {
if fuseFd <= 0 {
// if can not get fuse fd, do not serve for it
fdLog.V(1).Info("get fuse fd error, ignore it", "fusePath", fusePath)
return
}

Expand Down Expand Up @@ -338,6 +340,7 @@ func GetFuseFd(path string, close bool) (int, []byte) {
exists, err = k8sMount.PathExists(path)
return
}); err != nil {
fdLog.V(1).Info("path exists error", "path", path)
return -1, nil
}

Expand Down
10 changes: 8 additions & 2 deletions pkg/juicefs/juicefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ func (fs *jfs) BindTarget(ctx context.Context, bindSource, target string) error
}
// target is bind by other path, umount it
log.Info("target bind mount to other path, umount it", "target", target)
util.UmountPath(ctx, target)
_ = util.DoWithTimeout(ctx, defaultCheckTimeout, func() error {
util.UmountPath(ctx, target)
return nil
})
}
// bind target to mountpath
log.Info("binding source at target", "source", bindSource, "target", target)
Expand Down Expand Up @@ -578,7 +581,10 @@ func (j *juicefs) CreateTarget(ctx context.Context, target string) error {
return os.MkdirAll(target, os.FileMode(0755))
} else if corruptedMnt = mount.IsCorruptedMnt(err); corruptedMnt {
// if target is a corrupted mount, umount it
util.UmountPath(ctx, target)
_ = util.DoWithTimeout(ctx, defaultCheckTimeout, func() error {
util.UmountPath(ctx, target)
return nil
})
continue
} else {
return err
Expand Down

0 comments on commit 7ce0dc7

Please sign in to comment.