Skip to content

Commit

Permalink
Merge pull request #214 from mauriciopoppe/remove-mkdirall
Browse files Browse the repository at this point in the history
Remove mkdir call while creating the registration probe file
  • Loading branch information
k8s-ci-robot authored Aug 13, 2022
2 parents d0de3ef + 2d19977 commit c560a1e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
5 changes: 3 additions & 2 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
)

var socketFileName = "reg.sock"
var kubeletRegistrationPath = "/var/lib/kubelet/plugins/csi-dummy/registration"

// TestSocketFileDoesNotExist - Test1: file does not exist. So clean up should be successful.
func TestSocketFileDoesNotExist(t *testing.T) {
Expand Down Expand Up @@ -184,7 +183,9 @@ func TestTouchFile(t *testing.T) {
}
defer os.RemoveAll(testDir)

filePath := filepath.Join(testDir, kubeletRegistrationPath)
// In real life, testDir would be the kubeletRegistration socket dirname
// e.g. /var/lib/kubelet/plugins/<driver>/
filePath := filepath.Join(testDir, "registration")
fileExists, err := DoesFileExist(filePath)
if err != nil {
t.Fatalf("Failed to execute file exist: %+v", err)
Expand Down
6 changes: 0 additions & 6 deletions pkg/util/util_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package util
import (
"fmt"
"os"
"path/filepath"

"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -88,11 +87,6 @@ func TouchFile(filePath string) error {
return err
}
if !exists {
err := os.MkdirAll(filepath.Dir(filePath), 0755)
if err != nil {
return err
}

file, err := os.Create(filePath)
if err != nil {
return err
Expand Down
6 changes: 0 additions & 6 deletions pkg/util/util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
)

func Umask(mask int) (int, error) {
Expand Down Expand Up @@ -86,11 +85,6 @@ func TouchFile(filePath string) error {
return err
}
if !exists {
err := os.MkdirAll(filepath.Dir(filePath), 0755)
if err != nil {
return err
}

file, err := os.Create(filePath)
if err != nil {
return err
Expand Down

0 comments on commit c560a1e

Please sign in to comment.