Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[release-1.31] feat: replace Get-Item powershell cmd with golang api on Windows HostProcess mode #2183

Merged
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
1 change: 0 additions & 1 deletion pkg/mounter/safe_mounter_host_process_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (mounter *winMounter) Unmount(target string) error {
klog.V(2).Infof("remote server path: %s, local path: %s", remoteServer, target)
if hasDupSMBMount, err := smb.CheckForDuplicateSMBMounts(driverGlobalMountPath, target, remoteServer, mounter.volStatsCache); err == nil {
if !hasDupSMBMount {
remoteServer = strings.Replace(remoteServer, "UNC\\", "\\\\", 1)
if err := smb.RemoveSmbGlobalMapping(remoteServer); err != nil {
klog.Errorf("RemoveSmbGlobalMapping(%s) failed with %v", target, err)
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/os/smb/smb.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ func GetRemoteServerFromTarget(mount string, volStatsCache azcache.Resource) (st
klog.V(6).Infof("GetRemoteServerFromTarget(%s) cache hit: %s", mount, remoteServer)
return remoteServer, nil
}
cmd := "(Get-Item -Path $Env:mount).Target"
out, err := util.RunPowershellCmd(cmd, fmt.Sprintf("mount=%s", mount))
if err != nil || len(out) == 0 {
return "", fmt.Errorf("error getting volume from mount. cmd: %s, output: %s, error: %v", cmd, string(out), err)
target, err := os.Readlink(mount)
klog.V(2).Infof("read link for mount %s, target: %s", mount, target)
if err != nil || len(target) == 0 {
return "", fmt.Errorf("error reading link for mount %s. target %s err: %v", mount, target, err)
}
remoteServer := strings.TrimSpace(string(out))
remoteServer := strings.TrimSpace(target)
// cache the remote server path
volStatsCache.Set(mount, remoteServer)
return remoteServer, nil
Expand Down
Loading