Skip to content

Commit

Permalink
merge#53629: fix azure file mount limit issue on windows due to using…
Browse files Browse the repository at this point in the history
… drive letter (kubernetes#22)
  • Loading branch information
andyzhangx authored and ACS CI committed May 16, 2018
1 parent 6ee230d commit 523d109
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
22 changes: 2 additions & 20 deletions pkg/util/mount/mount_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
`$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord`,
options[0], options[1])

driverLetter, err := getAvailableDriveLetter()
if err != nil {
return err
}
bindSource = driverLetter + ":"
cmdLine += fmt.Sprintf(";New-SmbGlobalMapping -LocalPath %s -RemotePath %s -Credential $Credential", bindSource, source)
bindSource = source
cmdLine += fmt.Sprintf(";New-SmbGlobalMapping -RemotePath %s -Credential $Credential", source)

if output, err := exec.Command("powershell", "/c", cmdLine).CombinedOutput(); err != nil {
// we don't return error here, even though New-SmbGlobalMapping failed, we still make it successful,
Expand Down Expand Up @@ -354,20 +350,6 @@ func normalizeWindowsPath(path string) string {
return normalizedPath
}

func getAvailableDriveLetter() (string, error) {
cmd := "$used = Get-PSDrive | Select-Object -Expand Name | Where-Object { $_.Length -eq 1 }"
cmd += ";$drive = 67..90 | ForEach-Object { [string][char]$_ } | Where-Object { $used -notcontains $_ } | Select-Object -First 1;$drive"
output, err := exec.Command("powershell", "/c", cmd).CombinedOutput()
if err != nil {
return "", fmt.Errorf("getAvailableDriveLetter failed: %v, output: %q", err, string(output))
}

if len(output) == 0 {
return "", fmt.Errorf("azureMount: there is no available drive letter now")
}
return string(output)[:1], nil
}

// ValidateDiskNumber : disk number should be a number in [0, 99]
func ValidateDiskNumber(disk string) error {
diskNum, err := strconv.Atoi(disk)
Expand Down
2 changes: 0 additions & 2 deletions pkg/util/mount/mount_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (
"os/exec"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
)

func TestNormalizeWindowsPath(t *testing.T) {
Expand Down

0 comments on commit 523d109

Please sign in to comment.