Skip to content

Commit

Permalink
Remove mkdir call while creating the registration probe file
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciopoppe committed Aug 4, 2022
1 parent c759a11 commit e8ed512
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 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
5 changes: 0 additions & 5 deletions pkg/util/util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,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 e8ed512

Please sign in to comment.