diff --git a/driver/driver.go b/driver/driver.go index a2dfe3d0e..47eb8333a 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -25,6 +25,7 @@ import ( "strconv" "strings" "syscall" + "time" ) const ( @@ -636,6 +637,19 @@ func (p *S3fsPlugin) mountInternal(mountRequest interfaces.FlexVolumeMountReques return fmt.Errorf("s3fs mount failed: %s", string(out)) } + // Wait for 1 second before checking whether s3fs process really terminated + time.Sleep(1 * time.Second) + // Check whether s3fs process terminated + cmd := "ps aux | grep " + podUID + " | grep s3fs | grep -v grep" + output, err = command("bash", "-c", cmd).CombinedOutput() + if err == nil { + s3fsProcStatus := strings.SplitAfterN(string(output), "\n", 2) + if s3fsProcStatus[1] == "" { + p.Logger.Error(podUID + ":" + "s3fs process terminated.") + return fmt.Errorf("s3fs mount failed: s3fs process terminated.") + } + } + fInfo, err = os.Lstat(mountRequest.MountDir) if err == nil { p.Logger.Info(podUID+":"+"Target directory after-mount: ",