Skip to content

Commit 02fe5ac

Browse files
authored
Merge pull request #280 from andyzhangx/windows-convert-source-path
fix: convert source path on Windows
2 parents 5bd27bb + b129e0d commit 02fe5ac

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

deploy/example/e2e_usage.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-sm
6464
```
6565
- Execute `df -h` command in the container
6666
```console
67-
# k exec -it statefulset-smb2-0 sh
68-
# df -h
67+
kubectl exec -it statefulset-smb2-0 sh -- df -h
68+
```
69+
<pre>
6970
Filesystem Size Used Avail Use% Mounted on
7071
...
7172
//smb-server.default.svc.cluster.local/share 124G 23G 102G 19% /mnt/smb
7273
/dev/sda1 124G 15G 110G 12% /etc/hosts
7374
...
74-
```
75+
</pre>
7576

7677
### Option#2: PV/PVC Usage
7778
#### 1. Create PV/PVC bound with SMB share
@@ -124,14 +125,16 @@ kubectl create -f https://raw.githubusercontent.com/kubernetes-csi/csi-driver-sm
124125

125126
- Execute `df -h` command in the container
126127
```console
127-
$ kubectl exec -it nginx-smb -- sh
128-
# df -h
128+
kubectl exec -it nginx-smb -- df -h
129+
```
130+
<pre>
129131
Filesystem Size Used Avail Use% Mounted on
130132
...
131133
/dev/sda1 97G 21G 77G 22% /etc/hosts
132134
//20.43.191.64/share 97G 21G 77G 22% /mnt/smb
133135
...
134-
```
136+
</pre>
137+
135138
In the above example, there is a `/mnt/smb` directory mounted as cifs filesystem.
136139

137140
### 2.2 Create a deployment on Windows

pkg/mounter/safe_mounter_windows.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,19 @@ func (mounter *CSIProxyMounter) SMBMount(source, target, fsType string, mountOpt
6666

6767
if !parentExists {
6868
klog.Infof("Parent directory %s does not exists. Creating the directory", parentDir)
69-
err := mounter.MakeDir(parentDir)
70-
if err != nil {
69+
if err := mounter.MakeDir(parentDir); err != nil {
7170
return fmt.Errorf("create of parent dir: %s dailed with error: %v", parentDir, err)
7271
}
7372
}
7473

74+
source = strings.Replace(source, "/", "\\", -1)
7575
smbMountRequest := &smb.NewSmbGlobalMappingRequest{
7676
LocalPath: normalizeWindowsPath(target),
7777
RemotePath: source,
7878
Username: mountOptions[0],
7979
Password: sensitiveMountOptions[0],
8080
}
81-
_, err = mounter.SMBClient.NewSmbGlobalMapping(context.Background(), smbMountRequest)
82-
if err != nil {
81+
if _, err := mounter.SMBClient.NewSmbGlobalMapping(context.Background(), smbMountRequest); err != nil {
8382
return fmt.Errorf("smb mapping failed with error: %v", err)
8483
}
8584
return nil

test/e2e/dynamic_provisioning_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
6262

6363
testDriver = driver.InitSMBDriver()
6464
ginkgo.It("should create a volume after driver restart [smb.csi.k8s.io]", func() {
65+
ginkgo.Skip("test case is disabled since node logs would be lost after driver restart")
6566
pod := testsuites.PodDetails{
6667
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' >> /mnt/test-1/data && while true; do sleep 3600; done"),
6768
Volumes: []testsuites.VolumeDetails{

test/e2e/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ var _ = ginkgo.BeforeSuite(func() {
128128
gomega.Expect(err).NotTo(gomega.HaveOccurred())
129129

130130
smbPublicIP := strings.TrimSuffix(string(output), "\n")
131-
source := `\\` + smbPublicIP + `\share`
131+
source := `//` + smbPublicIP + `/share`
132132

133133
log.Printf("use source on Windows: %v\n", source)
134134
defaultStorageClassParameters["source"] = source

0 commit comments

Comments
 (0)