From 72e8359bbb74d45f449045fb5a77fa6bbed78391 Mon Sep 17 00:00:00 2001 From: xieydd Date: Thu, 10 Feb 2022 19:05:42 +0800 Subject: [PATCH 1/5] fix clean cache linux version error Signed-off-by: xieydd --- pkg/ddc/goosefs/operations/cached.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pkg/ddc/goosefs/operations/cached.go b/pkg/ddc/goosefs/operations/cached.go index 596e92ddd10..2d8f3081980 100644 --- a/pkg/ddc/goosefs/operations/cached.go +++ b/pkg/ddc/goosefs/operations/cached.go @@ -61,11 +61,27 @@ func (a GooseFSFileUtils) CachedState() (cached int64, err error) { // clean cache with a preset timeout of 60s func (a GooseFSFileUtils) CleanCache(path string) (err error) { var ( - command = []string{"timeout", "-k", "60", "60", "goosefs", "fs", "free", "-f", path} - stdout string - stderr string + releaseVersion = []string{"cat", "/etc/issue"} + command = []string{"60", "goosefs", "fs", "free", "-f", path} + stdout string + stderr string ) + stdout, stderr, err = a.exec(releaseVersion, false) + if err != nil { + err = fmt.Errorf("execute command %v with expectedErr: %v stdout %s and stderr %s", releaseVersion, err, stdout, stderr) + return + } + + if strings.Contains(stdout, "Ubuntu") { + command = append([]string{"timeout"}, command...) + } else if strings.Contains(stdout, "Alpine") { + command = append([]string{"timeout", "-t"}, command...) + } else { + err = fmt.Errorf("unknow release version for linux") + return + } + stdout, stderr, err = a.exec(command, false) if err != nil { err = fmt.Errorf("execute command %v with expectedErr: %v stdout %s and stderr %s", command, err, stdout, stderr) From da73b29826ae06281ff861d500e7038cc01b0d93 Mon Sep 17 00:00:00 2001 From: xieydd Date: Thu, 10 Feb 2022 20:29:09 +0800 Subject: [PATCH 2/5] update goosefs default image to 1.2.0 Signed-off-by: xieydd --- charts/fluid/fluid/values.yaml | 4 ++-- pkg/common/goosefs.go | 4 ++-- pkg/ddc/goosefs/shutdown_test.go | 4 ++-- pkg/ddc/goosefs/utils_test.go | 28 ++++++++++++++-------------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/charts/fluid/fluid/values.yaml b/charts/fluid/fluid/values.yaml index 8f1ec051707..3556b37e28d 100644 --- a/charts/fluid/fluid/values.yaml +++ b/charts/fluid/fluid/values.yaml @@ -58,9 +58,9 @@ runtime: controller: image: fluidcloudnative/goosefsruntime-controller:v0.7.0-37a4cd0 runtime: - image: ccr.ccs.tencentyun.com/qcloud/goosefs:v1.1.0-kona_jdk11 + image: ccr.ccs.tencentyun.com/qcloud/goosefs:v1.2.0 fuse: - image: ccr.ccs.tencentyun.com/qcloud/goosefs:v1.1.0-kona_jdk11 + image: ccr.ccs.tencentyun.com/qcloud/goosefs-fuse:v1.2.0 juicefs: enabled: false controller: diff --git a/pkg/common/goosefs.go b/pkg/common/goosefs.go index 5f73626cc98..e432bc46740 100644 --- a/pkg/common/goosefs.go +++ b/pkg/common/goosefs.go @@ -30,9 +30,9 @@ const ( GooseFSFuseImageEnv = "GOOSEFS_FUSE_IMAGE_ENV" - DefaultGooseFSRuntimeImage = "ccr.ccs.tencentyun.com/goosefs/goosefs:v1.0.1" + DefaultGooseFSRuntimeImage = "ccr.ccs.tencentyun.com/qcloud/goosefs:v1.2.0" - DefaultGooseFSFuseImage = "ccr.ccs.tencentyun.com/goosefs/goosefs-fuse:v1.0.1" + DefaultGooseFSFuseImage = "ccr.ccs.tencentyun.com/qcloud/goosefs-fuse:v1.2.0" ) var ( diff --git a/pkg/ddc/goosefs/shutdown_test.go b/pkg/ddc/goosefs/shutdown_test.go index 95e5618e902..9ae5bf655e4 100644 --- a/pkg/ddc/goosefs/shutdown_test.go +++ b/pkg/ddc/goosefs/shutdown_test.go @@ -28,7 +28,7 @@ var ( mockConfigMapData = `---- fullnameOverride: mnist image: ccr.ccs.tencentyun.com/qcloud/goosefs -imageTag: v1.1.0 +imageTag: v1.2.0 imagePullPolicy: IfNotPresent user: 0 group: 0 @@ -135,7 +135,7 @@ fuse: image: ccr.ccs.tencentyun.com/qcloud/goosefs-fuse nodeSelector: fluid.io/f-yijiupi-mnist: "true" - imageTag: v1.1.0 + imageTag: v1.2.0 env: MOUNT_POINT: /runtime-mnt/goosefs/yijiupi/mnist/goosefs-fuse jvmOptions: diff --git a/pkg/ddc/goosefs/utils_test.go b/pkg/ddc/goosefs/utils_test.go index 68d04d5ade0..7fb378a6793 100644 --- a/pkg/ddc/goosefs/utils_test.go +++ b/pkg/ddc/goosefs/utils_test.go @@ -776,12 +776,12 @@ func TestParseRuntimeImage(t *testing.T) { { name: "test0", args: args{ - image: "ccr.ccs.tencentyun.com/goosefs/goosefs", - tag: "v1.0.1", + image: "ccr.ccs.tencentyun.com/qcloud/goosefs", + tag: "v1.2.0", imagePullPolicy: "IfNotPresent", }, - want: "ccr.ccs.tencentyun.com/goosefs/goosefs", - want1: "v1.0.1", + want: "ccr.ccs.tencentyun.com/qcloud/goosefs", + want1: "v1.2.0", want2: "IfNotPresent", }, { @@ -791,15 +791,15 @@ func TestParseRuntimeImage(t *testing.T) { tag: "", imagePullPolicy: "IfNotPresent", }, - want: "ccr.ccs.tencentyun.com/goosefs/goosefs", - want1: "v1.0.1", + want: "ccr.ccs.tencentyun.com/qcloud/goosefs", + want1: "v1.2.0", want2: "IfNotPresent", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { e := &GooseFSEngine{} - os.Setenv(common.GooseFSRuntimeImageEnv, "ccr.ccs.tencentyun.com/goosefs/goosefs:v1.0.1") + os.Setenv(common.GooseFSRuntimeImageEnv, "ccr.ccs.tencentyun.com/qcloud/goosefs:v1.2.0") got, got1, got2 := e.parseRuntimeImage(tt.args.image, tt.args.tag, tt.args.imagePullPolicy) if got != tt.want { t.Errorf("GooseFSEngine.parseRuntimeImage() got = %v, want %v", got, tt.want) @@ -830,12 +830,12 @@ func TestParseFuseImage(t *testing.T) { { name: "test0", args: args{ - image: "ccr.ccs.tencentyun.com/goosefs/goosefs-fuse", - tag: "v1.0.1", + image: "ccr.ccs.tencentyun.com/qcloud/goosefs-fuse", + tag: "v1.2.0", imagePullPolicy: "IfNotPresent", }, - want: "ccr.ccs.tencentyun.com/goosefs/goosefs-fuse", - want1: "v1.0.1", + want: "ccr.ccs.tencentyun.com/qcloud/goosefs-fuse", + want1: "v1.2.0", want2: "IfNotPresent", }, { @@ -845,15 +845,15 @@ func TestParseFuseImage(t *testing.T) { tag: "", imagePullPolicy: "IfNotPresent", }, - want: "ccr.ccs.tencentyun.com/goosefs/goosefs-fuse", - want1: "v1.0.1", + want: "ccr.ccs.tencentyun.com/qcloud/goosefs-fuse", + want1: "v1.2.0", want2: "IfNotPresent", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { e := &GooseFSEngine{} - os.Setenv(common.GooseFSFuseImageEnv, "ccr.ccs.tencentyun.com/goosefs/goosefs-fuse:v1.0.1") + os.Setenv(common.GooseFSFuseImageEnv, "ccr.ccs.tencentyun.com/qcloud/goosefs-fuse:v1.2.0") got, got1, got2 := e.parseFuseImage(tt.args.image, tt.args.tag, tt.args.imagePullPolicy) if got != tt.want { t.Errorf("GooseFSEngine.parseFuseImage() got = %v, want %v", got, tt.want) From 8165dd7ee6c2a05110430344eac8381cc5edf18f Mon Sep 17 00:00:00 2001 From: xieydd Date: Fri, 11 Feb 2022 11:33:35 +0800 Subject: [PATCH 3/5] fix comment Signed-off-by: xieydd --- pkg/ddc/goosefs/operations/cached_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/ddc/goosefs/operations/cached_test.go b/pkg/ddc/goosefs/operations/cached_test.go index ab6d5eead6f..ab6cb949a14 100644 --- a/pkg/ddc/goosefs/operations/cached_test.go +++ b/pkg/ddc/goosefs/operations/cached_test.go @@ -16,6 +16,7 @@ package operations import ( "errors" + "fmt" "testing" "github.com/brahma-adshonor/gohook" @@ -68,6 +69,9 @@ func TestGooseFSFIlUtils_CleanCache(t *testing.T) { ExecCommonAlpine := func(a GooseFSFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) { return "Alpine", "", nil } + ExecCommonCentos := func(a GooseFSFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) { + return "", "", fmt.Errorf("unknow release version for linux") + } ExecErr := func(a GooseFSFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) { return "", "", errors.New("fail to run the command") } @@ -108,4 +112,14 @@ func TestGooseFSFIlUtils_CleanCache(t *testing.T) { t.Errorf("check failure, want nil, got err: %v", err) } wrappedUnhookExec() + + err = gohook.Hook(GooseFSFileUtils.exec, ExecCommonCentos, nil) + if err != nil { + t.Fatal(err.Error()) + } + err = a.CleanCache("/") + if err == nil { + t.Error("check failure, want err, got nil") + } + wrappedUnhookExec() } From 27f5814b5492e883efcb79ad4d7612b043bfadbb Mon Sep 17 00:00:00 2001 From: xieydd Date: Fri, 11 Feb 2022 14:57:57 +0800 Subject: [PATCH 4/5] fix timeout option for ubuntu and alpine base image Signed-off-by: xieydd --- pkg/ddc/alluxio/operations/cached.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/ddc/alluxio/operations/cached.go b/pkg/ddc/alluxio/operations/cached.go index 77fdbe803d3..6e2fe491ce3 100644 --- a/pkg/ddc/alluxio/operations/cached.go +++ b/pkg/ddc/alluxio/operations/cached.go @@ -74,9 +74,9 @@ func (a AlluxioFileUtils) CleanCache(path string) (err error) { } if strings.Contains(stdout, "Ubuntu") { - command = append([]string{"timeout"}, command...) + command = append([]string{"timeout", "-k"}, command...) } else if strings.Contains(stdout, "Alpine") { - command = append([]string{"timeout", "-t"}, command...) + command = append([]string{"timeout"}, command...) } else { err = fmt.Errorf("unknow release version for linux") return From 2f2ddcb39880e845b90ae416437b58f91e534335 Mon Sep 17 00:00:00 2001 From: xieydd Date: Fri, 11 Feb 2022 15:03:17 +0800 Subject: [PATCH 5/5] fix timeout option for ubuntu and alpine base image Signed-off-by: xieydd --- pkg/ddc/alluxio/operations/cached.go | 4 ++-- pkg/ddc/goosefs/operations/cached.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/ddc/alluxio/operations/cached.go b/pkg/ddc/alluxio/operations/cached.go index 6e2fe491ce3..77fdbe803d3 100644 --- a/pkg/ddc/alluxio/operations/cached.go +++ b/pkg/ddc/alluxio/operations/cached.go @@ -74,9 +74,9 @@ func (a AlluxioFileUtils) CleanCache(path string) (err error) { } if strings.Contains(stdout, "Ubuntu") { - command = append([]string{"timeout", "-k"}, command...) - } else if strings.Contains(stdout, "Alpine") { command = append([]string{"timeout"}, command...) + } else if strings.Contains(stdout, "Alpine") { + command = append([]string{"timeout", "-t"}, command...) } else { err = fmt.Errorf("unknow release version for linux") return diff --git a/pkg/ddc/goosefs/operations/cached.go b/pkg/ddc/goosefs/operations/cached.go index 2d8f3081980..21c799a5da2 100644 --- a/pkg/ddc/goosefs/operations/cached.go +++ b/pkg/ddc/goosefs/operations/cached.go @@ -74,9 +74,9 @@ func (a GooseFSFileUtils) CleanCache(path string) (err error) { } if strings.Contains(stdout, "Ubuntu") { - command = append([]string{"timeout"}, command...) + command = append([]string{"timeout", "-k"}, command...) } else if strings.Contains(stdout, "Alpine") { - command = append([]string{"timeout", "-t"}, command...) + command = append([]string{"timeout"}, command...) } else { err = fmt.Errorf("unknow release version for linux") return