Skip to content

Commit a55544d

Browse files
authored
Merge pull request #403 from andyzhangx/workingMountDir
feat: add workingMountDir in chart config
2 parents bfb8940 + 00d6060 commit a55544d

File tree

9 files changed

+41
-15
lines changed

9 files changed

+41
-15
lines changed

charts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ The following table lists the configurable parameters of the latest SMB CSI Driv
6464
| `controller.metricsPort` | metrics port of csi-smb-controller |`29644` |
6565
| `controller.livenessProbe.healthPort ` | health check port for liveness probe | `29642` |
6666
| `controller.logLevel` | controller driver log level |`5` |
67+
| `controller.workingMountDir` | working directory for provisioner to mount smb shares temporarily | `/tmp` |
6768
| `controller.runOnMaster` | run controller on master node | `false` |
6869
| `node.livenessProbe.healthPort ` | health check port for liveness probe | `29643` |
6970
| `controller.resources.csiProvisioner.limits.memory` | csi-provisioner memory limits | `100Mi` |
36 Bytes
Binary file not shown.

charts/latest/csi-driver-smb/templates/csi-smb-controller.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ spec:
8989
- "--endpoint=$(CSI_ENDPOINT)"
9090
- "--metrics-address=0.0.0.0:{{ .Values.controller.metricsPort }}"
9191
- "--drivername={{ .Values.driver.name }}"
92+
- "--working-mount-dir={{ .Values.controller.workingMountDir }}"
9293
ports:
9394
- containerPort: {{ .Values.controller.livenessProbe.healthPort }}
9495
name: healthz

charts/latest/csi-driver-smb/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ controller:
3939
healthPort: 29642
4040
runOnMaster: false
4141
logLevel: 5
42+
workingMountDir: "/tmp"
4243
resources:
4344
csiProvisioner:
4445
limits:

pkg/smb/controllerserver.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,6 @@ func getVolumeIDFromSmbVol(vol *smbVolume) string {
235235

236236
// Get working directory for CreateVolume and DeleteVolume
237237
func (d *Driver) getInternalMountPath(vol *smbVolume) string {
238-
// use default if empty
239-
if d.workingMountDir == "" {
240-
d.workingMountDir = "/tmp"
241-
}
242238
return filepath.Join(d.workingMountDir, vol.subDir)
243239
}
244240

pkg/smb/smb.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ const (
3939
defaultDomainName = "AZURE"
4040
)
4141

42+
// DriverOptions defines driver parameters specified in driver deployment
43+
type DriverOptions struct {
44+
NodeID string
45+
DriverName string
46+
EnableGetVolumeStats bool
47+
WorkingMountDir string
48+
}
49+
4250
// Driver implements all interfaces of CSI drivers
4351
type Driver struct {
4452
csicommon.CSIDriver
@@ -52,12 +60,13 @@ type Driver struct {
5260

5361
// NewDriver Creates a NewCSIDriver object. Assumes vendor version is equal to driver version &
5462
// does not support optional driver plugin info manifest field. Refer to CSI spec for more details.
55-
func NewDriver(nodeID, driverName string, enableGetVolumeStats bool) *Driver {
63+
func NewDriver(options *DriverOptions) *Driver {
5664
driver := Driver{}
57-
driver.Name = driverName
65+
driver.Name = options.DriverName
5866
driver.Version = driverVersion
59-
driver.NodeID = nodeID
60-
driver.enableGetVolumeStats = enableGetVolumeStats
67+
driver.NodeID = options.NodeID
68+
driver.enableGetVolumeStats = options.EnableGetVolumeStats
69+
driver.workingMountDir = options.WorkingMountDir
6170
driver.volumeLocks = newVolumeLocks()
6271
return &driver
6372
}

pkg/smb/smb_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,21 @@ const (
3030
)
3131

3232
func NewFakeDriver() *Driver {
33-
return NewDriver(fakeNodeID, DefaultDriverName, true)
33+
options := DriverOptions{
34+
NodeID: fakeNodeID,
35+
DriverName: DefaultDriverName,
36+
EnableGetVolumeStats: true,
37+
}
38+
return NewDriver(&options)
3439
}
3540

3641
func TestNewFakeDriver(t *testing.T) {
37-
// Test New fake driver.
38-
d := NewDriver(fakeNodeID, DefaultDriverName, true)
42+
options := DriverOptions{
43+
NodeID: fakeNodeID,
44+
DriverName: DefaultDriverName,
45+
EnableGetVolumeStats: true,
46+
}
47+
d := NewDriver(&options)
3948
assert.NotNil(t, d)
4049
}
4150

pkg/smbplugin/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var (
4343
metricsAddress = flag.String("metrics-address", "0.0.0.0:29644", "export the metrics")
4444
kubeconfig = flag.String("kubeconfig", "", "Absolute path to the kubeconfig file. Required only when running out of cluster.")
4545
enableGetVolumeStats = flag.Bool("enable-get-volume-stats", false, "allow GET_VOLUME_STATS on agent node")
46+
workingMountDir = flag.String("working-mount-dir", "/tmp", "working directory for provisioner to mount smb shares temporarily")
4647
)
4748

4849
func main() {
@@ -65,10 +66,13 @@ func main() {
6566
}
6667

6768
func handle() {
68-
driver := smb.NewDriver(*nodeID, *driverName, *enableGetVolumeStats)
69-
if driver == nil {
70-
klog.Fatalln("Failed to initialize smb CSI Driver")
69+
driverOptions := smb.DriverOptions{
70+
NodeID: *nodeID,
71+
DriverName: *driverName,
72+
EnableGetVolumeStats: *enableGetVolumeStats,
73+
WorkingMountDir: *workingMountDir,
7174
}
75+
driver := smb.NewDriver(&driverOptions)
7276
driver.Run(*endpoint, *kubeconfig, false)
7377
}
7478

test/e2e/suite_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ var _ = ginkgo.BeforeSuite(func() {
113113

114114
nodeid := os.Getenv("nodeid")
115115
kubeconfig := os.Getenv(kubeconfigEnvVar)
116-
smbDriver = smb.NewDriver(nodeid, smb.DefaultDriverName, false)
116+
options := smb.DriverOptions{
117+
NodeID: nodeid,
118+
DriverName: smb.DefaultDriverName,
119+
EnableGetVolumeStats: false,
120+
}
121+
smbDriver = smb.NewDriver(&options)
117122
go func() {
118123
smbDriver.Run(fmt.Sprintf("unix:///tmp/csi-%s.sock", uuid.NewUUID().String()), kubeconfig, false)
119124
}()

0 commit comments

Comments
 (0)