Skip to content
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/project-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid

- name: Lint golang code
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: latest
args: --timeout 10m --verbose
Expand Down
18 changes: 9 additions & 9 deletions hack/sdk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func main() {
}

func swaggify(name string) string {
name = strings.Replace(name, "github.com/fluid-cloudnative/fluid/api/v1alpha1", "", -1)
name = strings.Replace(name, "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/", "", -1)
name = strings.Replace(name, "k8s.io/api/core/", "", -1)
name = strings.Replace(name, "k8s.io/apimachinery/pkg/apis/meta/", "", -1)
name = strings.Replace(name, "k8s.io/kubernetes/pkg/controller/", "", -1)
name = strings.Replace(name, "k8s.io/client-go/listers/core/", "", -1)
name = strings.Replace(name, "k8s.io/client-go/util/workqueue", "", -1)
name = strings.Replace(name, "k8s.io/apimachinery/pkg/api/resource", "", -1)
name = strings.Replace(name, "/", ".", -1)
name = strings.ReplaceAll(name, "github.com/fluid-cloudnative/fluid/api/v1alpha1", "")
name = strings.ReplaceAll(name, "github.com/kubernetes-sigs/kube-batch/pkg/client/clientset/", "")
name = strings.ReplaceAll(name, "k8s.io/api/core/", "")
name = strings.ReplaceAll(name, "k8s.io/apimachinery/pkg/apis/meta/", "")
name = strings.ReplaceAll(name, "k8s.io/kubernetes/pkg/controller/", "")
name = strings.ReplaceAll(name, "k8s.io/client-go/listers/core/", "")
name = strings.ReplaceAll(name, "k8s.io/client-go/util/workqueue", "")
name = strings.ReplaceAll(name, "k8s.io/apimachinery/pkg/api/resource", "")
name = strings.ReplaceAll(name, "/", ".")
return name
}
6 changes: 3 additions & 3 deletions pkg/application/inject/fuse/injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4225,9 +4225,9 @@ func TestInjectPodUnprivileged(t *testing.T) {
for _, injectedFuse := range testcase.fuse {
for _, wantVolume := range injectedFuse.Spec.Template.Spec.Volumes {
// Skip check for volumes like "<runtime>-fuse-mount" and "<runtime>-fuse-device"
if wantVolume.VolumeSource.HostPath != nil &&
(strings.HasPrefix(wantVolume.VolumeSource.HostPath.Path, "/dev") ||
strings.HasPrefix(wantVolume.VolumeSource.HostPath.Path, "/runtime-mnt")) {
if wantVolume.HostPath != nil &&
(strings.HasPrefix(wantVolume.HostPath.Path, "/dev") ||
strings.HasPrefix(wantVolume.HostPath.Path, "/runtime-mnt")) {
continue
}
wantTemp := wantVolume.DeepCopy()
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
}

for _, tc := range testCases {
os.Unsetenv(utils.MountRoot)
_ = os.Unsetenv(utils.MountRoot)
if tc.expected != getMountRoot() {
t.Errorf("expected %#v, got %#v",
tc.expected, getMountRoot())
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/base/template_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var _ = Describe("TemplateEngine", func() {
BeforeEach(func() {
ctrl = gomock.NewController(GinkgoT())
impl = enginemock.NewMockImplement(ctrl)
os.Setenv("FLUID_SYNC_RETRY_DURATION", "0s")
_ = os.Setenv("FLUID_SYNC_RETRY_DURATION", "0s")
t = base.NewTemplateEngine(impl, "default-test", fakeCtx)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/goosefs/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
}

for _, tc := range testCases {
os.Unsetenv(utils.MountRoot)
_ = os.Unsetenv(utils.MountRoot)
if tc.expected != getMountRoot() {
t.Errorf("expected %#v, got %#v",
tc.expected, getMountRoot())
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindo/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
}

for _, tc := range testCases {
os.Unsetenv(utils.MountRoot)
_ = os.Unsetenv(utils.MountRoot)
if tc.expected != getMountRoot() {
t.Errorf("expected %#v, got %#v",
tc.expected, getMountRoot())
Expand Down
5 changes: 4 additions & 1 deletion pkg/ddc/jindocache/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ func TestTransformAllocatePorts(t *testing.T) {
// }

func TestJindoCacheEngine_transformMasterResources(t *testing.T) {
os.Setenv("USE_DEFAULT_MEM_LIMIT", "true")
err := os.Setenv("USE_DEFAULT_MEM_LIMIT", "true")
if err != nil {
t.Errorf("set env failed %v", err)
}
type fields struct {
name string
namespace string
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindocache/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
}

for _, tc := range testCases {
os.Unsetenv(utils.MountRoot)
_ = os.Unsetenv(utils.MountRoot)
if tc.expected != getMountRoot() {
t.Errorf("expected %#v, got %#v",
tc.expected, getMountRoot())
Expand Down
5 changes: 4 additions & 1 deletion pkg/ddc/jindofsx/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ func TestTransformAllocatePorts(t *testing.T) {
// }

func TestJindoFSxEngine_transformMasterResources(t *testing.T) {
os.Setenv("USE_DEFAULT_MEM_LIMIT", "true")
err := os.Setenv("USE_DEFAULT_MEM_LIMIT", "true")
if err != nil {
t.Errorf("failed to set env USE_DEFAULT_MEM_LIMIT")
}
type fields struct {
name string
namespace string
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/jindofsx/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
}

for _, tc := range testCases {
os.Unsetenv(utils.MountRoot)
_ = os.Unsetenv(utils.MountRoot)
if tc.expected != getMountRoot() {
t.Errorf("expected %#v, got %#v",
tc.expected, getMountRoot())
Expand Down
4 changes: 3 additions & 1 deletion pkg/ddc/vineyard/operations/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ func (a VineyardFileUtils) ReportSummary() (summary []string, err error) {
err = fmt.Errorf("failed to get metrics from %s, error: %v", u.String(), err)
return summary, err
}
defer resp.Body.Close()
defer func() {
_ = resp.Body.Close()
}()

body, err = io.ReadAll(resp.Body)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/ddc/vineyard/transform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
}
for k, test := range tests {
if strings.Contains(k, "env") {
os.Setenv("VINEYARD_FUSE_IMAGE_ENV", "image-from-env:image-tag-from-env")
_ = os.Setenv("VINEYARD_FUSE_IMAGE_ENV", "image-from-env:image-tag-from-env")
}
runtimeInfo, err := base.BuildRuntimeInfo("test", "fluid", "vineyard")
if err != nil {
Expand Down Expand Up @@ -110,7 +110,7 @@
t.Errorf("Expected Fuse Env %v, got %v", test.expectEnv, test.value.Fuse.Env)
}
if strings.Contains(k, "env") {
os.Unsetenv("VINEYARD_FUSE_IMAGE_ENV")
_ = os.Unsetenv("VINEYARD_FUSE_IMAGE_ENV")
}
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@
ds := &datav1alpha1.Dataset{}
for k, v := range testCases {
if strings.Contains(k, "env") {
os.Setenv("VINEYARD_MASTER_IMAGE_ENV", "image-from-env:image-tag-from-env")
_ = os.Setenv("VINEYARD_MASTER_IMAGE_ENV", "image-from-env:image-tag-from-env")
}
gotValue := &Vineyard{}
if err := engine.transformMasters(v.runtime, ds, gotValue); err == nil {
Expand All @@ -191,7 +191,7 @@
}
}
if strings.Contains(k, "env") {
os.Unsetenv("VINEYARD_MASTER_IMAGE_ENV")
_ = os.Unsetenv("VINEYARD_MASTER_IMAGE_ENV")
}
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@
engine := &VineyardEngine{Log: fake.NullLogger()}
for k, v := range testCases {
if strings.Contains(k, "env") {
os.Setenv("VINEYARD_WORKER_IMAGE_ENV", "image-from-env:image-tag-from-env")

Check failure on line 249 in pkg/ddc/vineyard/transform_test.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `os.Setenv` is not checked (errcheck)
}
gotValue := &Vineyard{}
engine.runtimeInfo, _ = base.BuildRuntimeInfo("test", "test", "vineyard", base.WithTieredStore(v.runtime.Spec.TieredStore))
Expand Down Expand Up @@ -281,7 +281,7 @@
}
}
if strings.Contains(k, "env") {
os.Unsetenv("VINEYARD_WORKER_IMAGE_ENV")
_ = os.Unsetenv("VINEYARD_WORKER_IMAGE_ENV")
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/utils/crtl_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,17 @@ func TestGenerateRandomRequeueDurationFromEnv(t *testing.T) {
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if test.runtimeReconcileDuration != "" {
os.Setenv(RuntimeReconcileDurationEnv, test.runtimeReconcileDuration)
_ = os.Setenv(RuntimeReconcileDurationEnv, test.runtimeReconcileDuration)
}
if test.runtimeReconcileOffset != "" {
os.Setenv(RuntimeReconcileDurationOffsetEnv, test.runtimeReconcileOffset)
_ = os.Setenv(RuntimeReconcileDurationOffsetEnv, test.runtimeReconcileOffset)
}
defer os.Unsetenv(RuntimeReconcileDurationEnv)
defer os.Unsetenv(RuntimeReconcileDurationOffsetEnv)
defer func() {
_ = os.Unsetenv(RuntimeReconcileDurationEnv)
}()
defer func() {
_ = os.Unsetenv(RuntimeReconcileDurationOffsetEnv)
}()
if envVal, exists := os.LookupEnv(RuntimeReconcileDurationEnv); exists {
RuntimeReconcileDurationEnvVal = envVal
stdlog.Printf("Found %s value %s, using it as RuntimeReconcileDurationEnvVal", RuntimeReconcileDurationEnv, envVal)
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestMountRootWithoutEnvSet(t *testing.T) {
{"/var/lib/mymount", ""},
}
for _, tc := range testCases {
os.Unsetenv(MountRoot)
_ = os.Unsetenv(MountRoot)
mountRoot, err := GetMountRoot()
if err == nil {
t.Errorf("Expected error happened, but no error")
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/mountinfo/mountinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ func loadMountInfo() (map[string]*Mount, error) {
if err != nil {
return nil, err
}
defer file.Close()
defer func() {
_ = file.Close()
}()
mountsByPath, err := readMountInfo(file)
if err != nil {
return nil, err
Expand Down
4 changes: 3 additions & 1 deletion pkg/utils/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
return err
}

defer file.Close()
defer func() {
file.Close()

Check failure on line 44 in pkg/utils/yaml.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `file.Close` is not checked (errcheck)
}()
_, err = file.Write(data)
if err != nil {
log.Error(err, "failed to write file", "data", data, "fileName", file.Name())
Expand Down
Loading