From a9276860d37847817285c7d61b97ffa3794c371e Mon Sep 17 00:00:00 2001 From: Mayank Sachan <34068620+mssachan@users.noreply.github.com> Date: Mon, 6 May 2019 18:24:46 +0530 Subject: [PATCH 1/2] fail POD creation if s3fs process terminates immediately --- driver/driver.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/driver/driver.go b/driver/driver.go index a2dfe3d0e..c235a1c49 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: ", From cfa6701e027bc175c181eec40a99e9ad208480b0 Mon Sep 17 00:00:00 2001 From: Mayank Sachan <34068620+mssachan@users.noreply.github.com> Date: Tue, 7 May 2019 11:16:18 +0530 Subject: [PATCH 2/2] Fix formatting issues --- driver/driver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/driver.go b/driver/driver.go index c235a1c49..47eb8333a 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -645,7 +645,7 @@ func (p *S3fsPlugin) mountInternal(mountRequest interfaces.FlexVolumeMountReques if err == nil { s3fsProcStatus := strings.SplitAfterN(string(output), "\n", 2) if s3fsProcStatus[1] == "" { - p.Logger.Error(podUID+":"+"s3fs process terminated.") + p.Logger.Error(podUID + ":" + "s3fs process terminated.") return fmt.Errorf("s3fs mount failed: s3fs process terminated.") } }