From 2a721bf3ebc082c75b1e18f4bde8daffe8489dd6 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 4 Dec 2023 15:24:28 +0000 Subject: [PATCH 01/11] feat: support windows host-process fix --- pkg/csi-common/utils.go | 18 ++ .../safe_mounter_host_process_windows.go | 286 ++++++++++++++++++ pkg/mounter/safe_mounter_unix.go | 2 +- pkg/mounter/safe_mounter_unix_test.go | 2 +- pkg/mounter/safe_mounter_windows.go | 18 +- pkg/os/filesystem/filesystem.go | 188 ++++++++++++ pkg/os/smb/smb.go | 64 ++++ pkg/smb/fake_mounter.go | 2 +- pkg/smb/smb.go | 2 +- pkg/smb/smb_common_windows.go | 2 +- 10 files changed, 574 insertions(+), 10 deletions(-) create mode 100644 pkg/mounter/safe_mounter_host_process_windows.go create mode 100644 pkg/os/filesystem/filesystem.go create mode 100644 pkg/os/smb/smb.go diff --git a/pkg/csi-common/utils.go b/pkg/csi-common/utils.go index e9c86c2cacb..53d95aa9432 100644 --- a/pkg/csi-common/utils.go +++ b/pkg/csi-common/utils.go @@ -18,7 +18,10 @@ package csicommon import ( "fmt" + "os" + "os/exec" "strings" + "sync" "context" @@ -28,6 +31,10 @@ import ( "k8s.io/klog/v2" ) +const MaxPathLengthWindows = 260 + +var mutex = &sync.Mutex{} + func ParseEndpoint(ep string) (string, string, error) { if strings.HasPrefix(strings.ToLower(ep), "unix://") || strings.HasPrefix(strings.ToLower(ep), "tcp://") { s := strings.SplitN(ep, "://", 2) @@ -84,3 +91,14 @@ func logGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, h } return resp, err } + +func RunPowershellCmd(command string, envs ...string) ([]byte, error) { + // only one powershell command can be executed at a time to avoid OOM + mutex.Lock() + defer mutex.Unlock() + + cmd := exec.Command("powershell", "-Mta", "-NoProfile", "-Command", command) + cmd.Env = append(os.Environ(), envs...) + klog.V(8).Infof("Executing command: %q", cmd.String()) + return cmd.CombinedOutput() +} diff --git a/pkg/mounter/safe_mounter_host_process_windows.go b/pkg/mounter/safe_mounter_host_process_windows.go new file mode 100644 index 00000000000..1c69cc41241 --- /dev/null +++ b/pkg/mounter/safe_mounter_host_process_windows.go @@ -0,0 +1,286 @@ +//go:build windows +// +build windows + +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mounter + +import ( + "context" + "fmt" + "net" + "os" + filepath "path/filepath" + "strings" + + "k8s.io/klog/v2" + mount "k8s.io/mount-utils" + + "github.com/kubernetes-csi/csi-driver-smb/pkg/os/filesystem" + "github.com/kubernetes-csi/csi-driver-smb/pkg/os/smb" +) + +var _ CSIProxyMounter = &winMounter{} + +type winMounter struct { + RemoveSMBMappingDuringUnmount bool +} + +func NewWinMounter(removeSMBMappingDuringUnmount bool) *winMounter { + return &winMounter{ + RemoveSMBMappingDuringUnmount: removeSMBMappingDuringUnmount, + } +} + +func (mounter *winMounter) SMBMount(source, target, fsType, volumeID string, mountOptions, sensitiveMountOptions []string) error { + klog.V(2).Infof("SMBMount: remote path: %s local path: %s", source, target) + + if len(mountOptions) == 0 || len(sensitiveMountOptions) == 0 { + return fmt.Errorf("empty mountOptions(len: %d) or sensitiveMountOptions(len: %d) is not allowed", len(mountOptions), len(sensitiveMountOptions)) + } + + parentDir := filepath.Dir(target) + parentExists, err := mounter.ExistsPath(parentDir) + if err != nil { + return fmt.Errorf("parent dir: %s exist check failed with err: %v", parentDir, err) + } + + if !parentExists { + klog.V(2).Infof("Parent directory %s does not exists. Creating the directory", parentDir) + if err := mounter.MakeDir(parentDir); err != nil { + return fmt.Errorf("create of parent dir: %s dailed with error: %v", parentDir, err) + } + } + + parts := strings.FieldsFunc(source, Split) + if len(parts) > 0 && strings.HasSuffix(parts[0], "svc.cluster.local") { + domainName := parts[0] + klog.V(2).Infof("begin to replace hostname(%s) with IP for source(%s)", domainName, source) + ip, err := net.ResolveIPAddr("ip4", domainName) + if err != nil { + klog.Warningf("could not resolve name to IPv4 address for host %s, failed with error: %v", domainName, err) + } else { + klog.V(2).Infof("resolve the name of host %s to IPv4 address: %s", domainName, ip.String()) + source = strings.Replace(source, domainName, ip.String(), 1) + } + } + + source = strings.Replace(source, "/", "\\", -1) + normalizedTarget := normalizeWindowsPath(target) + mappingPath, err := getRootMappingPath(source) + if mounter.RemoveSMBMappingDuringUnmount && err != nil { + return fmt.Errorf("getRootMappingPath(%s) failed with error: %v", source, err) + } + unlock := lock(mappingPath) + defer unlock() + + klog.V(2).Infof("begin to mount %s on %s", source, normalizedTarget) + + remotePath := source + localPath := normalizedTarget + + if remotePath == "" { + return fmt.Errorf("remote path is empty") + } + + isMapped, err := smb.IsSmbMapped(remotePath) + if err != nil { + isMapped = false + } + + if isMapped { + valid, err := filesystem.PathValid(context.Background(), remotePath) + if err != nil { + klog.Warningf("PathValid(%s) failed with %v, ignore error", remotePath, err) + } + + if !valid { + klog.Warningf("RemotePath %s is not valid, removing now", remotePath) + if err := smb.RemoveSmbGlobalMapping(remotePath); err != nil { + klog.Errorf("RemoveSmbGlobalMapping(%s) failed with %v", remotePath, err) + return err + } + isMapped = false + } + } + + if !isMapped { + klog.V(2).Infof("Remote %s not mapped. Mapping now!", remotePath) + username := mountOptions[0] + password := sensitiveMountOptions[0] + if err := smb.NewSmbGlobalMapping(remotePath, username, password); err != nil { + klog.Errorf("NewSmbGlobalMapping(%s) failed with %v", remotePath, err) + return err + } + } + + if len(localPath) != 0 { + if err := filesystem.ValidatePathWindows(localPath); err != nil { + return err + } + if err := os.Symlink(remotePath, localPath); err != nil { + return fmt.Errorf("os.Symlink(%s, %s) failed with %v", remotePath, localPath, err) + } + } + + if mounter.RemoveSMBMappingDuringUnmount { + if err := incementVolumeIDReferencesCount(mappingPath, source, volumeID); err != nil { + return fmt.Errorf("incementRemotePathReferencesCount(%s, %s, %s) failed with error: %v", mappingPath, source, volumeID, err) + } + } + klog.V(2).Infof("mount %s on %s successfully", source, normalizedTarget) + return nil +} + +func (mounter *winMounter) SMBUnmount(target, volumeID string) error { + klog.V(4).Infof("SMBUnmount: local path: %s", target) + + if remotePath, err := os.Readlink(target); err != nil { + klog.Warningf("SMBUnmount: can't get remote path: %v", err) + } else { + remotePath = strings.TrimSuffix(remotePath, "\\") + mappingPath, err := getRootMappingPath(remotePath) + if mounter.RemoveSMBMappingDuringUnmount && err != nil { + return fmt.Errorf("getRootMappingPath(%s) failed with error: %v", remotePath, err) + } + klog.V(4).Infof("SMBUnmount: remote path: %s, mapping path: %s", remotePath, mappingPath) + + if mounter.RemoveSMBMappingDuringUnmount { + unlock := lock(mappingPath) + defer unlock() + + if err := decrementVolumeIDReferencesCount(mappingPath, volumeID); err != nil { + return fmt.Errorf("decrementRemotePathReferencesCount(%s, %s) failed with error: %v", mappingPath, volumeID, err) + } + count := getVolumeIDReferencesCount(mappingPath) + if count == 0 { + klog.V(2).Infof("begin to RemoveSmbGlobalMapping %s on %s", remotePath, target) + if err := smb.RemoveSmbGlobalMapping(remotePath); err != nil { + return fmt.Errorf("RemoveSmbGlobalMapping failed with error: %v", err) + } + klog.V(2).Infof("RemoveSmbGlobalMapping %s on %s successfully", remotePath, target) + } else { + klog.Infof("SMBUnmount: found %d links to %s", count, mappingPath) + } + } + } + + return mounter.Rmdir(target) +} + +// 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)) +} + +// Rmdir - delete the given directory +func (mounter *winMounter) Rmdir(path string) error { + return filesystem.Rmdir(normalizeWindowsPath(path), true) +} + +// Unmount - Removes the directory - equivalent to unmount on Linux. +func (mounter *winMounter) Unmount(target string) error { + klog.V(4).Infof("Unmount: %s", target) + return mounter.Rmdir(target) +} + +func (mounter *winMounter) List() ([]mount.MountPoint, error) { + return []mount.MountPoint{}, fmt.Errorf("List not implemented for CSIProxyMounter") +} + +func (mounter *winMounter) IsMountPoint(file string) (bool, error) { + isNotMnt, err := mounter.IsLikelyNotMountPoint(file) + if err != nil { + return false, err + } + return !isNotMnt, nil +} + +func (mounter *winMounter) IsMountPointMatch(mp mount.MountPoint, dir string) bool { + return mp.Path == dir +} + +// IsLikelyMountPoint - If the directory does not exists, the function will return os.ErrNotExist error. +// If the path exists, will check if its a link, if its a link then existence of target path is checked. +func (mounter *winMounter) IsLikelyNotMountPoint(path string) (bool, error) { + isExists, err := mounter.ExistsPath(path) + if err != nil { + return false, err + } + if !isExists { + return true, os.ErrNotExist + } + + response, err := filesystem.IsMountPoint(normalizeWindowsPath(path)) + if err != nil { + return false, err + } + return !response, nil +} + +// MakeDir - Creates a directory. +// 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)) +} + +// ExistsPath - Checks if a path exists. Unlike util ExistsPath, this call does not perform follow link. +func (mounter *winMounter) ExistsPath(path string) (bool, error) { + return filesystem.PathExists(normalizeWindowsPath(path)) +} + +func (mounter *winMounter) MountSensitive(source string, target string, fstype string, options []string, sensitiveOptions []string) error { + return fmt.Errorf("MountSensitive not implemented for winMounter") +} + +func (mounter *winMounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, sensitiveOptions []string) error { + return fmt.Errorf("MountSensitiveWithoutSystemd not implemented for winMounter") +} + +func (mounter *winMounter) MountSensitiveWithoutSystemdWithMountFlags(source string, target string, fstype string, options []string, sensitiveOptions []string, mountFlags []string) error { + return mounter.MountSensitive(source, target, fstype, options, sensitiveOptions /* sensitiveOptions */) +} + +func (mounter *winMounter) GetMountRefs(pathname string) ([]string, error) { + return []string{}, fmt.Errorf("GetMountRefs not implemented for winMounter") +} + +func (mounter *winMounter) EvalHostSymlinks(pathname string) (string, error) { + return "", fmt.Errorf("EvalHostSymlinks not implemented for winMounter") +} + +func (mounter *winMounter) GetFSGroup(pathname string) (int64, error) { + return -1, fmt.Errorf("GetFSGroup not implemented for winMounter") +} + +func (mounter *winMounter) GetSELinuxSupport(pathname string) (bool, error) { + return false, fmt.Errorf("GetSELinuxSupport not implemented for winMounter") +} + +func (mounter *winMounter) GetMode(pathname string) (os.FileMode, error) { + return 0, fmt.Errorf("GetMode not implemented for winMounter") +} + +// GetAPIVersions returns the versions of the client APIs this mounter is using. +func (mounter *winMounter) GetAPIVersions() string { + return "" +} + +func (mounter *winMounter) CanSafelySkipMountPointCheck() bool { + return false +} diff --git a/pkg/mounter/safe_mounter_unix.go b/pkg/mounter/safe_mounter_unix.go index 36a386d8069..efbf6f64e51 100644 --- a/pkg/mounter/safe_mounter_unix.go +++ b/pkg/mounter/safe_mounter_unix.go @@ -24,7 +24,7 @@ import ( utilexec "k8s.io/utils/exec" ) -func NewSafeMounter(_ bool) (*mount.SafeFormatAndMount, error) { +func NewSafeMounter(_, _ bool) (*mount.SafeFormatAndMount, error) { return &mount.SafeFormatAndMount{ Interface: mount.New(""), Exec: utilexec.New(), diff --git a/pkg/mounter/safe_mounter_unix_test.go b/pkg/mounter/safe_mounter_unix_test.go index 7991c4736b9..e620101f63c 100644 --- a/pkg/mounter/safe_mounter_unix_test.go +++ b/pkg/mounter/safe_mounter_unix_test.go @@ -23,7 +23,7 @@ import ( ) func TestNewSafeMounter(t *testing.T) { - resp, err := NewSafeMounter(true) + resp, err := NewSafeMounter(true, true) assert.NotNil(t, resp) assert.Nil(t, err) } diff --git a/pkg/mounter/safe_mounter_windows.go b/pkg/mounter/safe_mounter_windows.go index 52f0da75562..ff9fef3c186 100644 --- a/pkg/mounter/safe_mounter_windows.go +++ b/pkg/mounter/safe_mounter_windows.go @@ -42,8 +42,8 @@ import ( type CSIProxyMounter interface { mount.Interface - SMBMount(source, target, fsType string, mountOptions, sensitiveMountOptions []string, volumeID string) error - SMBUnmount(target string, volumeID string) error + SMBMount(source, target, fsType, volumeID string, mountOptions, sensitiveMountOptions []string) error + SMBUnmount(target, volumeID string) error MakeDir(path string) error Rmdir(path string) error IsMountPointMatch(mp mount.MountPoint, dir string) bool @@ -68,7 +68,7 @@ func normalizeWindowsPath(path string) string { return normalizedPath } -func (mounter *csiProxyMounter) SMBMount(source, target, fsType string, mountOptions, sensitiveMountOptions []string, volumeID string) error { +func (mounter *csiProxyMounter) SMBMount(source, target, fsType, volumeID string, mountOptions, sensitiveMountOptions []string) error { klog.V(2).Infof("SMBMount: remote path: %s local path: %s", source, target) if len(mountOptions) == 0 || len(sensitiveMountOptions) == 0 { @@ -131,7 +131,7 @@ func (mounter *csiProxyMounter) SMBMount(source, target, fsType string, mountOpt return nil } -func (mounter *csiProxyMounter) SMBUnmount(target string, volumeID string) error { +func (mounter *csiProxyMounter) SMBUnmount(target, volumeID string) error { klog.V(4).Infof("SMBUnmount: local path: %s", target) if remotePath, err := os.Readlink(target); err != nil { @@ -369,7 +369,15 @@ func NewCSIProxyMounter(removeSMBMappingDuringUnmount bool) (*csiProxyMounter, e }, nil } -func NewSafeMounter(removeSMBMappingDuringUnmount bool) (*mount.SafeFormatAndMount, error) { +func NewSafeMounter(enableWindowsHostProcess, removeSMBMappingDuringUnmount bool) (*mount.SafeFormatAndMount, error) { + if enableWindowsHostProcess { + klog.V(2).Infof("using windows host process mounter") + return &mount.SafeFormatAndMount{ + Interface: NewWinMounter(removeSMBMappingDuringUnmount), + Exec: utilexec.New(), + }, nil + } + csiProxyMounter, err := NewCSIProxyMounter(removeSMBMappingDuringUnmount) if err == nil { klog.V(2).Infof("using CSIProxyMounterV1, %s", csiProxyMounter.GetAPIVersions()) diff --git a/pkg/os/filesystem/filesystem.go b/pkg/os/filesystem/filesystem.go new file mode 100644 index 00000000000..6fbcacbf792 --- /dev/null +++ b/pkg/os/filesystem/filesystem.go @@ -0,0 +1,188 @@ +/* +Copyright 2023 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package filesystem + +import ( + "context" + "fmt" + "os" + "regexp" + "strings" + + util "github.com/kubernetes-csi/csi-driver-smb/pkg/csi-common" + "k8s.io/klog/v2" +) + +var invalidPathCharsRegexWindows = regexp.MustCompile(`["/\:\?\*|]`) +var absPathRegexWindows = regexp.MustCompile(`^[a-zA-Z]:\\`) + +func containsInvalidCharactersWindows(path string) bool { + if isAbsWindows(path) { + path = path[3:] + } + if invalidPathCharsRegexWindows.MatchString(path) { + return true + } + if strings.Contains(path, `..`) { + return true + } + return false +} + +func isUNCPathWindows(path string) bool { + // check for UNC/pipe prefixes like "\\" + if len(path) < 2 { + return false + } + if path[0] == '\\' && path[1] == '\\' { + return true + } + return false +} + +func isAbsWindows(path string) bool { + // for Windows check for C:\\.. prefix only + // UNC prefixes of the form \\ are not considered + return absPathRegexWindows.MatchString(path) +} + +func pathExists(path string) (bool, error) { + _, err := os.Lstat(path) + if err == nil { + return true, nil + } + if os.IsNotExist(err) { + return false, nil + } + return false, err +} + +// PathExists checks if the given path exists on the host. +func PathExists(path string) (bool, error) { + if err := ValidatePathWindows(path); err != nil { + klog.Errorf("failed validatePathWindows %v", err) + return false, err + } + return pathExists(path) +} + +func PathValid(_ context.Context, path string) (bool, error) { + cmd := `Test-Path $Env:remotepath` + cmdEnv := fmt.Sprintf("remotepath=%s", path) + output, err := util.RunPowershellCmd(cmd, cmdEnv) + if err != nil { + return false, fmt.Errorf("returned output: %s, error: %v", string(output), err) + } + + return strings.HasPrefix(strings.ToLower(string(output)), "true"), nil +} + +func ValidatePathWindows(path string) error { + pathlen := len(path) + + if pathlen > util.MaxPathLengthWindows { + return fmt.Errorf("path length %d exceeds maximum characters: %d", pathlen, util.MaxPathLengthWindows) + } + + if pathlen > 0 && (path[0] == '\\') { + return fmt.Errorf("invalid character \\ at beginning of path: %s", path) + } + + if isUNCPathWindows(path) { + return fmt.Errorf("unsupported UNC path prefix: %s", path) + } + + if containsInvalidCharactersWindows(path) { + return fmt.Errorf("path contains invalid characters: %s", path) + } + + if !isAbsWindows(path) { + return fmt.Errorf("not an absolute Windows path: %s", path) + } + + 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 + } + + if force { + return os.RemoveAll(path) + } + 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 +// - it is a soft link and +// - 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) { + // This code is similar to k8s.io/kubernetes/pkg/util/mount except the pathExists usage. + stat, err := os.Lstat(tgt) + if err != nil { + return false, err + } + + // If its a link and it points to an existing file then its a mount point. + if stat.Mode()&os.ModeSymlink != 0 { + target, err := os.Readlink(tgt) + if err != nil { + return false, fmt.Errorf("readlink error: %v", err) + } + exists, err := pathExists(target) + if err != nil { + return false, err + } + return exists, nil + } + + return false, nil +} diff --git a/pkg/os/smb/smb.go b/pkg/os/smb/smb.go new file mode 100644 index 00000000000..83a71f2773e --- /dev/null +++ b/pkg/os/smb/smb.go @@ -0,0 +1,64 @@ +/* +Copyright 2023 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package smb + +import ( + "fmt" + "strings" + + util "github.com/kubernetes-csi/csi-driver-smb/pkg/csi-common" + "k8s.io/klog/v2" +) + +func IsSmbMapped(remotePath string) (bool, error) { + cmdLine := `$(Get-SmbGlobalMapping -RemotePath $Env:smbremotepath -ErrorAction Stop).Status` + cmdEnv := fmt.Sprintf("smbremotepath=%s", remotePath) + out, err := util.RunPowershellCmd(cmdLine, cmdEnv) + if err != nil { + return false, fmt.Errorf("error checking smb mapping. cmd %s, output: %s, err: %v", remotePath, string(out), err) + } + + if len(out) == 0 || !strings.EqualFold(strings.TrimSpace(string(out)), "OK") { + return false, nil + } + return true, nil +} + +func NewSmbGlobalMapping(remotePath, username, password string) error { + // use PowerShell Environment Variables to store user input string to prevent command line injection + // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-5.1 + cmdLine := fmt.Sprintf(`$PWord = ConvertTo-SecureString -String $Env:smbpassword -AsPlainText -Force` + + `;$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Env:smbuser, $PWord` + + `;New-SmbGlobalMapping -RemotePath $Env:smbremotepath -Credential $Credential -RequirePrivacy $true`) + + klog.V(2).Infof("begin to run NewSmbGlobalMapping with %s, %s", remotePath, username) + if output, err := util.RunPowershellCmd(cmdLine, fmt.Sprintf("smbuser=%s", username), + fmt.Sprintf("smbpassword=%s", password), + fmt.Sprintf("smbremotepath=%s", remotePath)); err != nil { + return fmt.Errorf("NewSmbGlobalMapping failed. output: %q, err: %v", string(output), err) + } + return nil +} + +func RemoveSmbGlobalMapping(remotePath string) error { + cmd := `Remove-SmbGlobalMapping -RemotePath $Env:smbremotepath -Force` + klog.V(2).Infof("begin to run RemoveSmbGlobalMapping with %s", remotePath) + if output, err := util.RunPowershellCmd(cmd, fmt.Sprintf("smbremotepath=%s", remotePath)); err != nil { + return fmt.Errorf("UnmountSmbShare failed. output: %q, err: %v", string(output), err) + } + return nil +} diff --git a/pkg/smb/fake_mounter.go b/pkg/smb/fake_mounter.go index c874ed6a33a..c06fdd2a6a0 100644 --- a/pkg/smb/fake_mounter.go +++ b/pkg/smb/fake_mounter.go @@ -65,7 +65,7 @@ func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) { func NewFakeMounter() (*mount.SafeFormatAndMount, error) { if runtime.GOOS == "windows" { - return mounter.NewSafeMounter(true) + return mounter.NewSafeMounter(true, true) } return &mount.SafeFormatAndMount{ Interface: &fakeMounter{}, diff --git a/pkg/smb/smb.go b/pkg/smb/smb.go index e2550befe38..6fd088f948a 100644 --- a/pkg/smb/smb.go +++ b/pkg/smb/smb.go @@ -128,7 +128,7 @@ func (d *Driver) Run(endpoint, _ string, testMode bool) { } klog.V(2).Infof("\nDRIVER INFORMATION:\n-------------------\n%s\n\nStreaming logs below:", versionMeta) - d.mounter, err = mounter.NewSafeMounter(d.removeSMBMappingDuringUnmount) + d.mounter, err = mounter.NewSafeMounter(false, d.removeSMBMappingDuringUnmount) if err != nil { klog.Fatalf("Failed to get safe mounter. Error: %v", err) } diff --git a/pkg/smb/smb_common_windows.go b/pkg/smb/smb_common_windows.go index 61a86eeeff0..019dc63afcb 100644 --- a/pkg/smb/smb_common_windows.go +++ b/pkg/smb/smb_common_windows.go @@ -30,7 +30,7 @@ import ( func Mount(m *mount.SafeFormatAndMount, source, target, fsType string, mountOptions, sensitiveMountOptions []string, volumeID string) error { if proxy, ok := m.Interface.(mounter.CSIProxyMounter); ok { - return proxy.SMBMount(source, target, fsType, mountOptions, sensitiveMountOptions, volumeID) + return proxy.SMBMount(source, target, fsType, volumeID, mountOptions, sensitiveMountOptions) } return fmt.Errorf("could not cast to csi proxy class") } From 8a759fd0949e77a735a283a2762b9f9cbfc4df95 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Tue, 5 Dec 2023 14:26:40 +0000 Subject: [PATCH 02/11] test: fix ut --- pkg/smb/fake_mounter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/smb/fake_mounter.go b/pkg/smb/fake_mounter.go index c06fdd2a6a0..cca65073bb4 100644 --- a/pkg/smb/fake_mounter.go +++ b/pkg/smb/fake_mounter.go @@ -65,7 +65,7 @@ func (f *fakeMounter) IsLikelyNotMountPoint(file string) (bool, error) { func NewFakeMounter() (*mount.SafeFormatAndMount, error) { if runtime.GOOS == "windows" { - return mounter.NewSafeMounter(true, true) + return mounter.NewSafeMounter(false, true) } return &mount.SafeFormatAndMount{ Interface: &fakeMounter{}, From b78e73c32abf9e1f652ed3c00beeb839a4e34bf4 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Wed, 6 Dec 2023 03:23:53 +0000 Subject: [PATCH 03/11] feat: add enable-windows-host-process flag --- charts/latest/csi-driver-smb-v0.0.0.tgz | Bin 4940 -> 4943 bytes cmd/smbplugin/main.go | 2 ++ pkg/smb/smb.go | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/charts/latest/csi-driver-smb-v0.0.0.tgz b/charts/latest/csi-driver-smb-v0.0.0.tgz index 427bb872c3519876be3a10a5eea01eabb825b418..8a852411b9802a716640ccd66b5fb89a73a051e7 100644 GIT binary patch delta 4092 zcmVN`3TruDfi4KygGYMSwIAwUokp?%`m4;W7)KTchnn>)+3In4_dumYaDosj!Ph^ zT(cBRnUoe|;BgW&dbhMp_}t8Rru^lEb4ABz68ZEqPbc7RS-?B&4SS>2XgeI(f_U)C z^Jo$YiQ8j<1-MAC1kiKzk2yr@^9y9^BCIQO^qB+!nty<4;wuZaq)88rK_EfV6bBp- znaYRgGmg~5goFIf5d9qWBt9AmMuPyDwq`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uxjVkwI*DJIzSL+Q->bI;k4l7Lj!^6#E7_R*6@02?+iNUE2 zK>^UsP47llx_>D&%M!ZPmUR?T^0&bu+f|x8M`8{flsIsN86Yl55TvmR-y9$hV=Tyo z1Vk)f$QH}*7@&l!``3!VXcR1^QB)TmP#>gqG!W&Z2?&hL;rsM1g!A!Rl;3&VW?Utd z9R|1FeB}slj!h49wcVy}$rcIjHB6`ucuJzn>S!~LY=6s*8zQT)=HA$HPb|3!JMJ>f zWmp^Wm6(aS^r_bEyx5v2}??KAtU0UmO{_OW=Z z%x@i&E`NW8gQI)N^U4;T+%&d7HflzG*At`Vd~4e@x<1;u$0WLO1OCj}?%HVR8TzVE zPVSlyZ?hZvkPZLuIlZ-GUi@h?*IMqr48umA{&l z_qq`ONt+=4R>!b+OmS-+l1Cr8Cj6Q647Jq!dY2+Cu%jmCZ^3AO1M)}T`$(PNYpH`Wd7VNY=iCa-nVW+(fRF5#b*ESoXeY;!PWaD^CNX!>KfB$3bt>M}KfAH)4;K&# z;~bev3t$sfVFsf60(Aqz)nE0qUh;z;8u`hWrXEzgEf9JECShx=I@xT)RlYpIhJV@A z@B++v%YL@(6D%MSTa29P%?s3xo6xQAmdA;djlFhgCx9NM%qLM%CTuvA)IQFjS!ds* z1TFafrG&dKw696zlW5jn?Ar@@<$hLYVo_i891_Z*Y+e3800960&X+@(0FVFx_`w4a diff --git a/cmd/smbplugin/main.go b/cmd/smbplugin/main.go index 3562a653832..1e6a61742a8 100644 --- a/cmd/smbplugin/main.go +++ b/cmd/smbplugin/main.go @@ -48,6 +48,7 @@ var ( krb5CacheDirectory = flag.String("krb5-cache-directory", smb.DefaultKrb5CacheDirectory, "The directory for kerberos cache") krb5Prefix = flag.String("krb5-prefix", smb.DefaultKrb5CCName, "The prefix for kerberos cache") defaultOnDeletePolicy = flag.String("default-ondelete-policy", "", "default policy for deleting subdirectory when deleting a volume") + enableWindowsHostProcess = flag.Bool("enable-windows-host-process", false, "enable windows host process") ) func main() { @@ -80,6 +81,7 @@ func handle() { Krb5CacheDirectory: *krb5CacheDirectory, Krb5Prefix: *krb5Prefix, DefaultOnDeletePolicy: *defaultOnDeletePolicy, + EnableWindowsHostProcess: *enableWindowsHostProcess, } driver := smb.NewDriver(&driverOptions) driver.Run(*endpoint, *kubeconfig, false) diff --git a/pkg/smb/smb.go b/pkg/smb/smb.go index 6fd088f948a..238e7cacc14 100644 --- a/pkg/smb/smb.go +++ b/pkg/smb/smb.go @@ -68,6 +68,7 @@ type DriverOptions struct { Krb5CacheDirectory string Krb5Prefix string DefaultOnDeletePolicy string + EnableWindowsHostProcess bool } // Driver implements all interfaces of CSI drivers @@ -86,6 +87,7 @@ type Driver struct { krb5CacheDirectory string krb5Prefix string defaultOnDeletePolicy string + enableWindowsHostProcess bool } // NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version & @@ -97,6 +99,7 @@ func NewDriver(options *DriverOptions) *Driver { driver.NodeID = options.NodeID driver.enableGetVolumeStats = options.EnableGetVolumeStats driver.removeSMBMappingDuringUnmount = options.RemoveSMBMappingDuringUnmount + driver.enableWindowsHostProcess = options.EnableWindowsHostProcess driver.workingMountDir = options.WorkingMountDir driver.volumeLocks = newVolumeLocks() @@ -128,7 +131,7 @@ func (d *Driver) Run(endpoint, _ string, testMode bool) { } klog.V(2).Infof("\nDRIVER INFORMATION:\n-------------------\n%s\n\nStreaming logs below:", versionMeta) - d.mounter, err = mounter.NewSafeMounter(false, d.removeSMBMappingDuringUnmount) + d.mounter, err = mounter.NewSafeMounter(d.enableWindowsHostProcess, d.removeSMBMappingDuringUnmount) if err != nil { klog.Fatalf("Failed to get safe mounter. Error: %v", err) } From 4e382197bf8604de1f03873c075fc9b3b5ea556f Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 7 Dec 2023 04:08:09 +0000 Subject: [PATCH 04/11] vendor: support hostprocess image build --- release-tools/build.make | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/release-tools/build.make b/release-tools/build.make index bceab34d267..1c539f97c4c 100644 --- a/release-tools/build.make +++ b/release-tools/build.make @@ -152,6 +152,7 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-% trap "docker buildx rm multiarchimage-buildertest" EXIT; \ dockerfile_linux=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile ]; then echo ./$(CMDS_DIR)/$*/Dockerfile; else echo Dockerfile; fi); \ dockerfile_windows=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile.Windows ]; then echo ./$(CMDS_DIR)/$*/Dockerfile.Windows; else echo Dockerfile.Windows; fi); \ + dockerfile_windows_hp=$$(if [ -e ./$(CMDS_DIR)/$*/Dockerfile.Windows.hostprocess ]; then echo ./$(CMDS_DIR)/$*/Dockerfile.Windows.hostprocess; else echo Dockerfile.Windows.hostprocess; fi); \ if [ '$(BUILD_PLATFORMS)' ]; then build_platforms='$(BUILD_PLATFORMS)'; else build_platforms="linux amd64"; fi; \ if ! [ -f "$$dockerfile_windows" ]; then \ build_platforms="$$(echo "$$build_platforms" | sed -e 's/windows *[^ ]* *[^ ]* *.exe *[^ ]* *[^ ]*//g' -e 's/; *;/;/g' -e 's/;[ ]*$$//')"; \ @@ -173,6 +174,18 @@ $(CMDS:%=push-multiarch-%): push-multiarch-%: check-pull-base-ref build-% --label revision=$(REV) \ .; \ done; \ + if ! [ -f "$$dockerfile_windows_hp" ]; then \ + docker buildx build --push \ + --tag $(IMAGE_NAME):$$escaped_buildx_platform-$$os-$$escaped_base_image$$tag-windows-hp \ + --platform=$$os/$$buildx_platform \ + --file $$(eval echo \$${dockerfile_$$os}) \ + --build-arg binary=./bin/$*$$suffix \ + --build-arg ARCH=$$arch \ + --label revision=$(REV) \ + .; \ + docker manifest create --amend $(IMAGE_NAME):$$tag-windows-hp; \ + docker manifest push -p $(IMAGE_NAME):$$tag-windows-hp; \ + fi; \ images=$$(echo "$$build_platforms" | tr ';' '\n' | while read -r os arch buildx_platform suffix base_image addon_image; do \ escaped_base_image=$${base_image/:/-}; \ escaped_buildx_platform=$${buildx_platform//\//-}; \ From 2102eb66a555cec73e7d9d9c20d5be9241df9cef Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Thu, 7 Dec 2023 04:10:34 +0000 Subject: [PATCH 05/11] add Dockerfile.Windows.hostprocess --- cmd/smbplugin/Dockerfile.Windows.hostprocess | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cmd/smbplugin/Dockerfile.Windows.hostprocess diff --git a/cmd/smbplugin/Dockerfile.Windows.hostprocess b/cmd/smbplugin/Dockerfile.Windows.hostprocess new file mode 100644 index 00000000000..e28225851a4 --- /dev/null +++ b/cmd/smbplugin/Dockerfile.Windows.hostprocess @@ -0,0 +1,24 @@ +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 +LABEL description="CSI SMB plugin" + +ARG ARCH=amd64 +ARG binary=./_output/${ARCH}/smbplugin.exe +COPY ${binary} /smbplugin.exe +ENV PATH="C:\Windows\system32;C:\Windows;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;" +USER ContainerAdministrator +ENTRYPOINT ["/smbplugin.exe"] + From 1590c29136799767881838b61c58691a326f1ec8 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Fri, 8 Dec 2023 14:32:21 +0000 Subject: [PATCH 06/11] fix: add lstc2022 image build support fix --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7f4dd257910..24420289fb5 100644 --- a/Makefile +++ b/Makefile @@ -156,8 +156,11 @@ container-linux-armv7: container-windows: docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" \ -t $(IMAGE_TAG)-windows-$(OSVERSION)-$(ARCH) --build-arg OSVERSION=$(OSVERSION) \ - --provenance=false --sbom=false \ - --build-arg ARCH=$(ARCH) -f ./cmd/smbplugin/Dockerfile.Windows . + --provenance=false --sbom=false \ + --build-arg ARCH=$(ARCH) \ + --build-arg ADDON_IMAGE=servercore:$(OSVERSION) \ + --build-arg BASE_IMAGE=nanoserver:$(OSVERSION) \ + -f ./cmd/smbplugin/Dockerfile.Windows . .PHONY: container-all container-all: smb-windows From 03240907067dedd02c477de94c4be74ae0c9ad59 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 10 Dec 2023 02:42:27 +0000 Subject: [PATCH 07/11] feat: add hpc chart support chore: set hostNetwork: true for host process deployment --- Makefile | 18 +++ charts/README.md | 1 + .../csi-smb-node-windows-hostprocess.yaml | 120 ++++++++++++++++++ .../templates/csi-smb-node-windows.yaml | 2 +- charts/latest/csi-driver-smb/values.yaml | 5 +- 5 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml diff --git a/Makefile b/Makefile index 24420289fb5..f4e220b23f4 100644 --- a/Makefile +++ b/Makefile @@ -98,11 +98,16 @@ e2e-test: .PHONY: e2e-bootstrap e2e-bootstrap: install-helm +ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS + (docker pull $(IMAGE_TAG) && docker pull $(CSI_IMAGEIMAGE_TAG_TAG)-windows-hp) || make container-all push-manifest +else docker pull $(IMAGE_TAG) || make container-all push-manifest +endif ifdef TEST_WINDOWS helm upgrade csi-driver-smb charts/$(VERSION)/csi-driver-smb --namespace kube-system --wait --timeout=15m -v=5 --debug --install \ ${E2E_HELM_OPTIONS} \ --set windows.enabled=true \ + --set windows.useHostProcessContainers=${WINDOWS_USE_HOST_PROCESS_CONTAINERS} \ --set linux.enabled=false \ --set controller.replicas=1 \ --set controller.logLevel=6 \ @@ -162,6 +167,19 @@ container-windows: --build-arg BASE_IMAGE=nanoserver:$(OSVERSION) \ -f ./cmd/smbplugin/Dockerfile.Windows . +# workaround: only build hostprocess image once +ifdef WINDOWS_USE_HOST_PROCESS_CONTAINERS +ifeq ($(OSVERSION),ltsc2022) + $(MAKE) container-windows-hostprocess +endif +endif + +# Set --provenance=false to not generate the provenance (which is what causes the multi-platform index to be generated, even for a single platform). +.PHONY: container-windows-hostprocess +container-windows-hostprocess: + docker buildx build --pull --output=type=$(OUTPUT_TYPE) --platform="windows/$(ARCH)" --provenance=false --sbom=false \ + -t $(IMAGE_TAG)-windows-hp -f ./cmd/smbplugin/Dockerfile.Windows.hostprocess . + .PHONY: container-all container-all: smb-windows docker buildx rm container-builder || true diff --git a/charts/README.md b/charts/README.md index 39cee34a6e3..59e2777e2dd 100644 --- a/charts/README.md +++ b/charts/README.md @@ -114,6 +114,7 @@ The following table lists the configurable parameters of the latest SMB CSI Driv | `linux.resources.smb.requests.cpu` | smb-csi-driver cpu requests limits | `10m` | | `linux.resources.smb.requests.memory` | smb-csi-driver memory requests limits | `20Mi` | | `windows.enabled` | whether enable windows feature | `false` | +| `windows.useHostProcessContainers` | whether deploy driver daemonset with host process containers on windows | `false` | | `windows.dsName` | name of driver daemonset on windows | `csi-smb-node-win` | | `windows.removeSMBMappingDuringUnmount` | remove SMBMapping during unmount on Windows node windows | `true` | | `windows.resources.livenessProbe.limits.memory` | liveness-probe memory limits | `200Mi` | diff --git a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml new file mode 100644 index 00000000000..a6ccb4f40a1 --- /dev/null +++ b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml @@ -0,0 +1,120 @@ +{{- if and .Values.windows.enabled .Values.windows.useHostProcessContainers }} +kind: DaemonSet +apiVersion: apps/v1 +metadata: + name: {{ .Values.windows.dsName }} + namespace: {{ .Release.Namespace }} +{{ include "smb.labels" . | indent 2 }} +spec: + updateStrategy: + rollingUpdate: + maxUnavailable: {{ .Values.node.maxUnavailable }} + type: RollingUpdate + selector: + matchLabels: + app: {{ .Values.windows.dsName }} + template: + metadata: +{{ include "smb.labels" . | indent 6 }} + app: {{ .Values.windows.dsName }} + spec: +{{- with .Values.windows.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} +{{- end }} + nodeSelector: + kubernetes.io/os: windows +{{- with .Values.node.nodeSelector }} +{{ toYaml . | indent 8 }} +{{- end }} +{{- with .Values.node.affinity }} + affinity: +{{ toYaml . | indent 8 }} +{{- end }} + priorityClassName: {{ .Values.priorityClassName | quote }} + securityContext: + seccompProfile: + type: RuntimeDefault + windowsOptions: + hostProcess: true + runAsUserName: "NT AUTHORITY\\SYSTEM" + hostNetwork: true + serviceAccountName: {{ .Values.serviceAccount.node }} + {{- include "smb.pullSecrets" . | indent 6 }} + initContainers: + - name: init +{{- if hasPrefix "/" .Values.image.smb.repository }} + image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp" +{{- else }} + image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp" +{{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - "powershell.exe" + - "-c" + - "New-Item -ItemType Directory -Path C:\\var\\lib\\kubelet\\plugins\\{{ .Values.driver.name }}\\ -Force" + containers: + - name: node-driver-registrar +{{- if hasPrefix "/" .Values.image.nodeDriverRegistrar.repository }} + image: "{{ .Values.image.baseRepo }}{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}" +{{- else }} + image: "{{ .Values.image.nodeDriverRegistrar.repository }}:{{ .Values.image.nodeDriverRegistrar.tag }}" +{{- end }} + command: + - "csi-node-driver-registrar.exe" + args: + - --v=2 + - --csi-address=$(CSI_ENDPOINT) + - --kubelet-registration-path=$(DRIVER_REG_SOCK_PATH) + - --plugin-registration-path=$(PLUGIN_REG_DIR) + env: + - name: CSI_ENDPOINT + value: unix://C:\\csi\\csi.sock + - name: DRIVER_REG_SOCK_PATH + value: {{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins\\{{ .Values.driver.name }}\\csi.sock + - name: PLUGIN_REG_DIR + value: {{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins_registry\\ + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + imagePullPolicy: {{ .Values.image.nodeDriverRegistrar.pullPolicy }} + resources: {{- toYaml .Values.windows.resources.nodeDriverRegistrar | nindent 12 }} + - name: smb +{{- if hasPrefix "/" .Values.image.smb.repository }} + image: "{{ .Values.image.baseRepo }}{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp" +{{- else }} + image: "{{ .Values.image.smb.repository }}:{{ .Values.image.smb.tag }}-windows-hp" +{{- end }} + imagePullPolicy: {{ .Values.image.smb.pullPolicy }} + command: + - "smbplugin.exe" + args: + - "--v={{ .Values.node.logLevel }}" + - "--drivername={{ .Values.driver.name }}" + - --endpoint=$(CSI_ENDPOINT) + - --nodeid=$(KUBE_NODE_NAME) + - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" + - "--remove-smb-mapping-during-unmount={{ .Values.windows.removeSMBMappingDuringUnmount }}" + ports: + - containerPort: {{ .Values.node.livenessProbe.healthPort }} + name: healthz + protocol: TCP + livenessProbe: + failureThreshold: 5 + httpGet: + path: /healthz + port: healthz + initialDelaySeconds: 30 + timeoutSeconds: 10 + periodSeconds: 30 + env: + - name: CSI_ENDPOINT + value: unix://C:\\csi\\csi.sock + - name: KUBE_NODE_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: spec.nodeName + resources: {{- toYaml .Values.windows.resources.smb | nindent 12 }} +{{- end -}} diff --git a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows.yaml b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows.yaml index b033b151c97..ad5663c6029 100755 --- a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows.yaml +++ b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows.yaml @@ -1,4 +1,4 @@ -{{- if .Values.windows.enabled}} +{{- if and .Values.windows.enabled (not .Values.windows.useHostProcessContainers) }} kind: DaemonSet apiVersion: apps/v1 metadata: diff --git a/charts/latest/csi-driver-smb/values.yaml b/charts/latest/csi-driver-smb/values.yaml index 068da019560..cd30fd819c4 100755 --- a/charts/latest/csi-driver-smb/values.yaml +++ b/charts/latest/csi-driver-smb/values.yaml @@ -117,7 +117,8 @@ linux: memory: 20Mi windows: - enabled: false # Unless you already had csi proxy installed, windows.csiproxy.enabled=true is required + enabled: false + useHostProcessContainers: false dsName: csi-smb-node-win # daemonset name kubelet: 'C:\var\lib\kubelet' removeSMBMappingDuringUnmount: true @@ -145,7 +146,7 @@ windows: cpu: 10m memory: 40Mi csiproxy: - enabled: false # required if windows.enabled is true, but may be installed manually also + enabled: false # set as false if csi-proxy is already installed on the node or useHostProcessContainers is true dsName: csi-proxy-win # daemonset name tolerations: {} affinity: {} From 1fff26feb89bc1542fbe15037331003f9b9f882c Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 10 Dec 2023 14:38:06 +0000 Subject: [PATCH 08/11] test: fix capz windows test failure fix capz windows test failure --- deploy/example/smb-provisioner/smb-server-lb.yaml | 7 +++++++ deploy/example/smb-provisioner/smb-server.yaml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/deploy/example/smb-provisioner/smb-server-lb.yaml b/deploy/example/smb-provisioner/smb-server-lb.yaml index 66c52516400..ddd50ad5b6e 100644 --- a/deploy/example/smb-provisioner/smb-server-lb.yaml +++ b/deploy/example/smb-provisioner/smb-server-lb.yaml @@ -30,6 +30,13 @@ spec: spec: nodeSelector: "kubernetes.io/os": linux + tolerations: + - key: "node-role.kubernetes.io/controlplane" + operator: "Exists" + effect: "NoSchedule" + - key: "node-role.kubernetes.io/control-plane" + operator: "Exists" + effect: "NoSchedule" containers: - name: smb-server image: andyzhangx/samba:win-fix diff --git a/deploy/example/smb-provisioner/smb-server.yaml b/deploy/example/smb-provisioner/smb-server.yaml index 588e77a4fd4..a33158e28bd 100644 --- a/deploy/example/smb-provisioner/smb-server.yaml +++ b/deploy/example/smb-provisioner/smb-server.yaml @@ -30,6 +30,13 @@ spec: spec: nodeSelector: "kubernetes.io/os": linux + tolerations: + - key: "node-role.kubernetes.io/controlplane" + operator: "Exists" + effect: "NoSchedule" + - key: "node-role.kubernetes.io/control-plane" + operator: "Exists" + effect: "NoSchedule" containers: - name: smb-server image: andyzhangx/samba:win-fix From c140edb1289e88e1be6ac0bb49939f57b11b4738 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 11 Dec 2023 10:12:24 +0000 Subject: [PATCH 09/11] fix: hostprocess chart config --- charts/latest/csi-driver-smb-v0.0.0.tgz | Bin 4943 -> 5252 bytes .../csi-smb-node-windows-hostprocess.yaml | 16 ++-------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/charts/latest/csi-driver-smb-v0.0.0.tgz b/charts/latest/csi-driver-smb-v0.0.0.tgz index 8a852411b9802a716640ccd66b5fb89a73a051e7..c24034a486e4ef825b8098a6d35cb9667accca4f 100644 GIT binary patch delta 5239 zcmV--6o~83CWI-FJb!6#<2bVO*+BmX!aczD>}&bT(fb7CLwAyy31&J8;`A&An?-|` z$~IplQA1KryqWy>2a>u)+47O2cTAu=wnSF(sEbua+Tp}<8JPjIxIgM1PcajnIrhEp zwpV(+Uhi;!U;XX%dgZ^p{^8)e{{CVA!{K0Xu($tRufN~h>wkTRdRy#6ZHc(R?7QB^ zxXOe3MhXteZ@@UAfsJPU77oMotA_<}(Q<)1jD$ix8-D(Tj)!OHM3D>{Q-*$tM!*6P zz*_~9+Hn-8lVY24! zKe)vOo{(T-KqpabPpzz(>cSQ6MC4hXEE~Bf%m-Z_z)e5U9`ZQCt^c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im4;c601%HXOwQ15Xf=9H2DD7#cY zx37P&>zW3zx~mG7@f#et6LP^A6z^|TS8%rO6iWi_!pl(38`m27{OMcKpBR~1l)Prib1wt>tBy5dUC!1}! z%9khDFq;})fH`m3&z60H1w>+tku$w{fx2-My7k@iIFYik*ADFj(4&<3Br3{;4TqB2 z#~C#1?3e7vaMy+QHHmx@&Dx87dm*pf&+1GJs@9t?lF9#pCpnCiTa|0>d2Vt! yavS9;m62KW*A?CN>J4R+xMG+K8v9F|??XA1LphYK%l`)e0RR8Fy!opDkN^OP+p%*1 diff --git a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml index a6ccb4f40a1..001677a7727 100644 --- a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml +++ b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml @@ -69,7 +69,7 @@ spec: - --plugin-registration-path=$(PLUGIN_REG_DIR) env: - name: CSI_ENDPOINT - value: unix://C:\\csi\\csi.sock + value: unix://{{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins\\{{ .Values.driver.name }}\\csi.sock - name: DRIVER_REG_SOCK_PATH value: {{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins\\{{ .Values.driver.name }}\\csi.sock - name: PLUGIN_REG_DIR @@ -96,21 +96,9 @@ spec: - --nodeid=$(KUBE_NODE_NAME) - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" - "--remove-smb-mapping-during-unmount={{ .Values.windows.removeSMBMappingDuringUnmount }}" - ports: - - containerPort: {{ .Values.node.livenessProbe.healthPort }} - name: healthz - protocol: TCP - livenessProbe: - failureThreshold: 5 - httpGet: - path: /healthz - port: healthz - initialDelaySeconds: 30 - timeoutSeconds: 10 - periodSeconds: 30 env: - name: CSI_ENDPOINT - value: unix://C:\\csi\\csi.sock + value: unix://{{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins\\{{ .Values.driver.name }}\\csi.sock - name: KUBE_NODE_NAME valueFrom: fieldRef: From 7361d78440a6828de897e3cacb83baccd3c2f52f Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 31 Dec 2023 12:33:48 +0000 Subject: [PATCH 10/11] test: use windows server ip address in host process deployment e2e test fix fix --- charts/latest/csi-driver-smb-v0.0.0.tgz | Bin 5252 -> 5266 bytes .../csi-smb-node-windows-hostprocess.yaml | 1 + test/e2e/dynamic_provisioning_test.go | 19 ++++++++++++++++++ test/e2e/suite_test.go | 1 + 4 files changed, 21 insertions(+) diff --git a/charts/latest/csi-driver-smb-v0.0.0.tgz b/charts/latest/csi-driver-smb-v0.0.0.tgz index c24034a486e4ef825b8098a6d35cb9667accca4f..bfbbea4f00bbc3136879d883740657e0a3245ead 100644 GIT binary patch delta 5218 zcmV-o6rJmYDUvCWJb!C%+qkm(*+BmT;V!V&ze9RTOw!pm=|Y;w8M$zGBN{Zaevf3o?<3CbL@NH zZLjotz24#ezWUqi^~!&H{lmd`{r$uKyTifY;NAXrz5af0Z-4(g)Z1boYD>fgX5aNT z##J8NH&Sp&{s6`a4Qw>)w{RGyUp*{l^2RBM)k?{#{eUh8X*cvteJ#Q!twMZmW#02cFqzqhw{Smyu1yTcv-KSv=x zo`Bs#XoNXjL4QbX#9%_WVDrxHPrO5Dmy?Ob1!Z^wErhr~lGPDn5K>MAWpf)%942et z{=_XV@Pq^tE7z*a{ZZ&e6B4L~0#9t@-~h9^`W{A}cS$|s%x!cwKBwZ60f#`ekQ61C zjLwJ@Ai%147j(5NDLc#>XQ*fUN)9bS?U5M-!1*PkBY#*8bJ8@FO>=k$o&I1s;()rK z#p{*Ef!7$g1d{MIOTZMn(qIl8PC`cS=Y|EJ#w(r*f4SgX_2Z5NF1_Q)0^HAYc>A4x zXRsJ;ivybx2i`jljRGNYI}ES@8wnNxdX4@$g+P6Ni{iQn>&hJ65zj*-h?}@dL(OT_ zK|>HoP=7SW9t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zjk;munOLxuT-3V@cC7Dvdd1i3elw*}{CC6OgIyB;-S1V;e+~9`@!w}Df2E+3x*RII z^mp?}t_HY^kW z0>a(3!og*+ybA{Jg25}_b5|D+HbQ-ZfbcCF9a#Do*N>{=BK>LhQsdWsjoeB`-K&qv zE>{SzH6pvY{fQReh4;)?+?92xQK2vz;)zluHu^+d<$5PHz@D)Of2xg=75S}Y00u@p z#?BP7)B5dpb$imR+ud7WBVd$ww=jUTXKDW{l6*BSx>D@2VIXC7{xLS@JZu;y}kVpAFA=c z-TiORQYxQC;F90P*=A_)Df*j5WwzPVhlfN8mxE}M z2N$h@dXFP9rHuSX>80wuo%#p+uc!x$hpJ%3c7p}?LT(tn{O`A@pWtacC>D9z$g!jm z{u857$ZhnmcKhG0k~Q_Ob|}Zg1q32Cj^au)U?Wvw0;2sMf3-cr)nE0q{_=yK8u`hU zsvcCkH4r);CVpeAI@oN&RlGdaggLI^c$o8s<7_x4m_Z=cn7Mc~?@>FfL$`cb4kwZ~ zwmP7V06LU1mjrp9FyT;K`!thgT>UsCXu$Vx#oSe<{X_zn1e4}$-<-)yzt3ciVpNTj zFQU=^fg@rrHa7~_%<^om1eys~DU9Mxe^t<}FWykPhzq7UC$V2zeecSy?8>gJUH(4+ O0RR8bxVoqSqyPX;;6>{I diff --git a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml index 001677a7727..43854dae821 100644 --- a/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml +++ b/charts/latest/csi-driver-smb/templates/csi-smb-node-windows-hostprocess.yaml @@ -96,6 +96,7 @@ spec: - --nodeid=$(KUBE_NODE_NAME) - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" - "--remove-smb-mapping-during-unmount={{ .Values.windows.removeSMBMappingDuringUnmount }}" + - "--enable-windows-host-process=true" env: - name: CSI_ENDPOINT value: unix://{{ .Values.windows.kubelet | replace "\\" "\\\\" }}\\plugins\\{{ .Values.driver.name }}\\csi.sock diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 3ba5bd6ec7e..16a85dc0e2c 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -18,11 +18,15 @@ package e2e import ( "fmt" + "log" + "os/exec" + "strings" "github.com/kubernetes-csi/csi-driver-smb/test/e2e/driver" "github.com/kubernetes-csi/csi-driver-smb/test/e2e/testsuites" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" clientset "k8s.io/client-go/kubernetes" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" @@ -51,6 +55,21 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { cs = f.ClientSet ns = f.Namespace + + if isUsingHostProcessDeployment { + log.Printf("trying to get smb-server service IP address since it's using host process deployment...") + cmd := exec.Command("kubectl", "get svc smb-server | grep smb | awk '{print $4}'") + output, err := cmd.CombinedOutput() + log.Printf("got output: %v, error: %v\n", string(output), err) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + + server := strings.TrimSuffix(string(output), "\n") + log.Printf("use server on Windows: %s\n", server) + newShareAddress := fmt.Sprintf("//%s/share", server) + defaultStorageClassParameters["source"] = newShareAddress + subDirStorageClassParameters["source"] = newShareAddress + noProvisionerSecretStorageClassParameters["source"] = newShareAddress + } }) testDriver = driver.InitSMBDriver() diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index 32a66fe0ddb..2e4ea240c12 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -53,6 +53,7 @@ const ( var ( smbDriver *smb.Driver isWindowsCluster = os.Getenv(testWindowsEnvVar) != "" + isUsingHostProcessDeployment = os.Getenv("WINDOWS_USE_HOST_PROCESS_CONTAINERS") == "true" defaultStorageClassParameters = map[string]string{ "source": getSmbTestEnvVarValue(testSmbSourceEnvVar, defaultSmbSource), "csi.storage.k8s.io/provisioner-secret-name": getSmbTestEnvVarValue(testSmbSecretNameEnvVar, defaultSmbSecretName), From bc9633723666c836ce09e6625fcbe7f0568a9989 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Sun, 31 Dec 2023 14:22:17 +0000 Subject: [PATCH 11/11] test: add get_smb_svc_public_ip.sh script fix golint --- test/e2e/dynamic_provisioning_test.go | 14 ++++++++++++-- test/utils/get_smb_svc_public_ip.sh | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/utils/get_smb_svc_public_ip.sh diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index 16a85dc0e2c..2c4e7512236 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -19,6 +19,7 @@ package e2e import ( "fmt" "log" + "os" "os/exec" "strings" @@ -57,8 +58,17 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { ns = f.Namespace if isUsingHostProcessDeployment { - log.Printf("trying to get smb-server service IP address since it's using host process deployment...") - cmd := exec.Command("kubectl", "get svc smb-server | grep smb | awk '{print $4}'") + err := os.Chdir("../..") + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + defer func() { + err := os.Chdir("test/e2e") + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + }() + + getSMBPublicIPScript := "test/utils/get_smb_svc_public_ip.sh" + log.Printf("run script: %s\n", getSMBPublicIPScript) + + cmd := exec.Command("bash", getSMBPublicIPScript) output, err := cmd.CombinedOutput() log.Printf("got output: %v, error: %v\n", string(output), err) gomega.Expect(err).NotTo(gomega.HaveOccurred()) diff --git a/test/utils/get_smb_svc_public_ip.sh b/test/utils/get_smb_svc_public_ip.sh new file mode 100644 index 00000000000..33a7751f777 --- /dev/null +++ b/test/utils/get_smb_svc_public_ip.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e +kubectl get svc smb-server | grep smb | awk '{print $4}' +