Skip to content

Commit

Permalink
improve error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Xuhui zhang <[email protected]>
  • Loading branch information
zxh326 committed Feb 11, 2025
1 parent 15cf6d6 commit 3a1e273
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/pod_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,9 @@ func (p *PodDriver) doAbortFuse(mountpod *corev1.Pod, devMinor uint32) error {
if err == nil {
log.Info("mount point is normal, don't need to abort fuse connection")
return nil
} else if err.Error() != "function timeout" {
log.Error(err, "stat mount point error")
return err
}
job := builder.NewFuseAbortJob(mountpod, devMinor, mntPath)
if _, err := p.Client.CreateJob(context.Background(), job); err != nil {
Expand Down
27 changes: 13 additions & 14 deletions pkg/juicefs/mount/builder/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,21 @@ func NewFuseAbortJob(mountpod *corev1.Pod, devMinor uint32, mntPath string) *bat
"sh",
"-c",
fmt.Sprintf(`
attempt=1
while [ $attempt -le 5 ]; do
if timeout 1 stat "%s"; then
echo "fuse mount success, exit 0"
exit 0
fi
sleep 1
attempt=$((attempt+1))
done
attempt=1
while [ $attempt -le 5 ]; do
if timeout 1 stat "%s"; then
echo "fuse mount success, exit 0"
exit 0
fi
sleep 1
attempt=$((attempt+1))
done
echo "fuse mount failed, aborting..."
echo "fuse mount failed, aborting..."
if [ $(cat /sys/fs/fuse/connections/%d/waiting) -gt 0 ]; then
echo 1 > /sys/fs/fuse/connections/%d/abort
fi
`, mntPath, devMinor, devMinor),
if [ $(cat /sys/fs/fuse/connections/%d/waiting) -gt 0 ]; then
echo 1 > /sys/fs/fuse/connections/%d/abort
fi`, mntPath, devMinor, devMinor),
},
SecurityContext: &corev1.SecurityContext{
Privileged: &privileged,
Expand Down

0 comments on commit 3a1e273

Please sign in to comment.