From 09673ff689fd50fc6dec441c3598fff60afd175e Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Tue, 10 Dec 2024 09:07:14 +0000 Subject: [PATCH] cleanup: windows functions --- deploy/example/windows/statefulset.yaml | 1 + .../safe_mounter_host_process_windows.go | 4 +-- pkg/os/filesystem/filesystem.go | 27 +------------------ 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/deploy/example/windows/statefulset.yaml b/deploy/example/windows/statefulset.yaml index a6dd2b9351..7e5dcb7f03 100644 --- a/deploy/example/windows/statefulset.yaml +++ b/deploy/example/windows/statefulset.yaml @@ -7,6 +7,7 @@ metadata: app: busybox spec: serviceName: statefulset-azurefile-win + podManagementPolicy: Parallel # default is OrderedReady replicas: 1 template: metadata: diff --git a/pkg/mounter/safe_mounter_host_process_windows.go b/pkg/mounter/safe_mounter_host_process_windows.go index bb13b84257..0fdeaa4e2d 100644 --- a/pkg/mounter/safe_mounter_host_process_windows.go +++ b/pkg/mounter/safe_mounter_host_process_windows.go @@ -120,7 +120,7 @@ func (mounter *winMounter) SMBMount(source, target, fsType string, mountOptions, // Mount just creates a soft link at target pointing to source. func (mounter *winMounter) Mount(source, target, fstype string, options []string) error { - return filesystem.LinkPath(normalizeWindowsPath(source), normalizeWindowsPath(target)) + return os.Symlink(normalizeWindowsPath(source), normalizeWindowsPath(target)) } // Rmdir - delete the given directory @@ -191,7 +191,7 @@ func (mounter *winMounter) IsLikelyNotMountPoint(path string) (bool, error) { // Currently the make dir is only used from the staging code path, hence we call it // with Plugin context.. func (mounter *winMounter) MakeDir(path string) error { - return filesystem.Mkdir(normalizeWindowsPath(path)) + return os.MkdirAll(normalizeWindowsPath(path), 0755) } // ExistsPath - Checks if a path exists. Unlike util ExistsPath, this call does not perform follow link. diff --git a/pkg/os/filesystem/filesystem.go b/pkg/os/filesystem/filesystem.go index 8a821369f0..d6f5395f64 100644 --- a/pkg/os/filesystem/filesystem.go +++ b/pkg/os/filesystem/filesystem.go @@ -117,13 +117,6 @@ func ValidatePathWindows(path string) error { return nil } -func Mkdir(path string) error { - if err := ValidatePathWindows(path); err != nil { - return err - } - return os.MkdirAll(path, 0755) -} - func Rmdir(path string, force bool) error { if err := ValidatePathWindows(path); err != nil { return err @@ -135,28 +128,10 @@ func Rmdir(path string, force bool) error { return os.Remove(path) } -func LinkPath(sourcePath, targetPath string) error { - return CreateSymlink(sourcePath, targetPath) -} - -func CreateSymlink(sourcePath, targetPath string) error { - if err := ValidatePathWindows(targetPath); err != nil { - return err - } - if err := ValidatePathWindows(sourcePath); err != nil { - return err - } - return os.Symlink(sourcePath, targetPath) -} - func IsMountPoint(path string) (bool, error) { return IsSymlink(path) } -func IsSymlink(path string) (bool, error) { - return isSymlink(path) -} - // IsSymlink - returns true if tgt is a mount point. // A path is considered a mount point if: // - directory exists and @@ -164,7 +139,7 @@ func IsSymlink(path string) (bool, error) { // - the target path of the link exists. // If tgt path does not exist, it returns an error // if tgt path exists, but the source path tgt points to does not exist, it returns false without error. -func isSymlink(tgt string) (bool, error) { +func IsSymlink(tgt string) (bool, error) { // This code is similar to k8s.io/kubernetes/pkg/util/mount except the pathExists usage. stat, err := os.Lstat(tgt) if err != nil {