Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GooseFS) [Bug Fix] Fix clean cache linux version error #1428

Merged
merged 5 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions charts/fluid/fluid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions pkg/common/goosefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
22 changes: 19 additions & 3 deletions pkg/ddc/goosefs/operations/cached.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "-k"}, command...)
} else if strings.Contains(stdout, "Alpine") {
command = append([]string{"timeout"}, command...)
} else {
err = fmt.Errorf("unknow release version for linux")
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you cover the test of L81-L82? Thanks.


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)
Expand Down
14 changes: 14 additions & 0 deletions pkg/ddc/goosefs/operations/cached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package operations

import (
"errors"
"fmt"
"testing"

"github.com/brahma-adshonor/gohook"
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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()
}
4 changes: 2 additions & 2 deletions pkg/ddc/goosefs/shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
28 changes: 14 additions & 14 deletions pkg/ddc/goosefs/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand All @@ -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)
Expand Down Expand Up @@ -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",
},
{
Expand All @@ -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)
Expand Down