@@ -69,11 +69,20 @@ const (
69
69
iSCSIIQNTemplate = "iqn.2003-01.io.k8s:e2e.%s"
70
70
)
71
71
72
+ type NFSProtocalVersion string
73
+
74
+ const (
75
+ NFSv3 NFSProtocalVersion = "3"
76
+ NFSv4 NFSProtocalVersion = "4"
77
+ )
78
+
72
79
// NFS
73
80
type nfsDriver struct {
74
81
externalProvisionerPod * v1.Pod
75
82
externalPluginName string
76
83
84
+ // path that is exported by the NFS server.
85
+ path string
77
86
driverInfo storageframework.DriverInfo
78
87
}
79
88
@@ -90,28 +99,43 @@ var _ storageframework.PreprovisionedPVTestDriver = &nfsDriver{}
90
99
var _ storageframework.DynamicPVTestDriver = & nfsDriver {}
91
100
92
101
// InitNFSDriver returns nfsDriver that implements TestDriver interface
93
- func InitNFSDriver () storageframework.TestDriver {
94
- return & nfsDriver {
95
- driverInfo : storageframework.DriverInfo {
96
- Name : "nfs" ,
97
- InTreePluginName : "kubernetes.io/nfs" ,
98
- MaxFileSize : storageframework .FileSizeLarge ,
99
- SupportedSizeRange : e2evolume.SizeRange {
100
- Min : "1Gi" ,
101
- },
102
- SupportedFsType : sets .NewString (
103
- "" , // Default fsType
104
- ),
105
- SupportedMountOption : sets .NewString ("relatime" ),
106
- RequiredMountOption : sets .NewString ("vers=4.0" ),
107
- Capabilities : map [storageframework.Capability ]bool {
108
- storageframework .CapPersistence : true ,
109
- storageframework .CapExec : true ,
110
- storageframework .CapRWX : true ,
111
- storageframework .CapMultiPODs : true ,
112
- storageframework .CapMultiplePVsSameID : true ,
102
+ func InitNFSDriver (version NFSProtocalVersion ) func () storageframework.TestDriver {
103
+ var driverName , path , mountOption string
104
+ switch version {
105
+ case NFSv3 :
106
+ driverName = "nfs3"
107
+ path = "/exports"
108
+ mountOption = "vers=3"
109
+ case NFSv4 :
110
+ driverName = "nfs"
111
+ path = "/"
112
+ mountOption = "vers=4.0"
113
+ }
114
+
115
+ return func () storageframework.TestDriver {
116
+ return & nfsDriver {
117
+ path : path ,
118
+ driverInfo : storageframework.DriverInfo {
119
+ Name : driverName ,
120
+ InTreePluginName : "kubernetes.io/nfs" ,
121
+ MaxFileSize : storageframework .FileSizeLarge ,
122
+ SupportedSizeRange : e2evolume.SizeRange {
123
+ Min : "1Gi" ,
124
+ },
125
+ SupportedFsType : sets .NewString (
126
+ "" , // Default fsType
127
+ ),
128
+ SupportedMountOption : sets .NewString ("relatime" ),
129
+ RequiredMountOption : sets .NewString (mountOption ),
130
+ Capabilities : map [storageframework.Capability ]bool {
131
+ storageframework .CapPersistence : true ,
132
+ storageframework .CapExec : true ,
133
+ storageframework .CapRWX : true ,
134
+ storageframework .CapMultiPODs : true ,
135
+ storageframework .CapMultiplePVsSameID : true ,
136
+ },
113
137
},
114
- },
138
+ }
115
139
}
116
140
}
117
141
@@ -130,7 +154,7 @@ func (n *nfsDriver) GetVolumeSource(readOnly bool, fsType string, e2evolume stor
130
154
return & v1.VolumeSource {
131
155
NFS : & v1.NFSVolumeSource {
132
156
Server : nv .serverHost ,
133
- Path : "/" ,
157
+ Path : n . path ,
134
158
ReadOnly : readOnly ,
135
159
},
136
160
}
@@ -144,15 +168,16 @@ func (n *nfsDriver) GetPersistentVolumeSource(readOnly bool, fsType string, e2ev
144
168
return & v1.PersistentVolumeSource {
145
169
NFS : & v1.NFSVolumeSource {
146
170
Server : nv .serverHost ,
147
- Path : "/" ,
171
+ Path : n . path ,
148
172
ReadOnly : readOnly ,
149
173
},
150
174
}, nil
151
175
}
152
176
153
177
func (n * nfsDriver ) GetDynamicProvisionStorageClass (ctx context.Context , config * storageframework.PerTestConfig , fsType string ) * storagev1.StorageClass {
154
178
provisioner := n .externalPluginName
155
- parameters := map [string ]string {"mountOptions" : "vers=4.0" }
179
+ mountOptions := strings .Join (n .driverInfo .RequiredMountOption .List (), "," )
180
+ parameters := map [string ]string {"mountOptions" : mountOptions }
156
181
ns := config .Framework .Namespace .Name
157
182
158
183
return storageframework .GetStorageClass (provisioner , parameters , nil , ns )
0 commit comments