@@ -33,7 +33,8 @@ import (
33
33
34
34
var (
35
35
defaultFSGroupPolicy = storagev1 .FileFSGroupPolicy
36
- reclaimPolicy = corev1 .PersistentVolumeReclaimRetain
36
+ reclaimPolicyRetain = corev1 .PersistentVolumeReclaimRetain
37
+ reclaimPolicyDelete = corev1 .PersistentVolumeReclaimDelete
37
38
secrets = crutils .GetImagePullSecrets (ibmObjectCSICR .Spec .ImagePullSecrets )
38
39
39
40
ibmObjectCSIReconcileRequest = reconcile.Request {
@@ -155,7 +156,7 @@ var (
155
156
156
157
csiNode = & appsv1.DaemonSet {
157
158
ObjectMeta : metav1.ObjectMeta {
158
- Name : config .GetNameForResource (config .CSINode , ibmObjectCSICRName ),
159
+ Name : config .GetNameForResource (config .CSINode , config . DriverPrefix ),
159
160
Namespace : TestNamespace ,
160
161
Annotations : annotations ,
161
162
},
@@ -166,7 +167,7 @@ var (
166
167
167
168
controllerDeployment = & appsv1.Deployment {
168
169
ObjectMeta : metav1.ObjectMeta {
169
- Name : config .GetNameForResource (config .CSIController , ibmObjectCSICRName ),
170
+ Name : config .GetNameForResource (config .CSIController , config . DriverPrefix ),
170
171
Namespace : TestNamespace ,
171
172
Annotations : annotations ,
172
173
},
@@ -196,77 +197,77 @@ var (
196
197
197
198
controllerSA = & corev1.ServiceAccount {
198
199
ObjectMeta : metav1.ObjectMeta {
199
- Name : config .GetNameForResource (config .CSIControllerServiceAccount , ibmObjectCSICRName ),
200
+ Name : config .GetNameForResource (config .CSIControllerServiceAccount , config . DriverPrefix ),
200
201
Namespace : TestNamespace ,
201
202
},
202
203
ImagePullSecrets : secrets ,
203
204
}
204
205
205
206
nodeSA = & corev1.ServiceAccount {
206
207
ObjectMeta : metav1.ObjectMeta {
207
- Name : config .GetNameForResource (config .CSINodeServiceAccount , ibmObjectCSICRName ),
208
+ Name : config .GetNameForResource (config .CSINodeServiceAccount , config . DriverPrefix ),
208
209
Namespace : TestNamespace ,
209
210
},
210
211
ImagePullSecrets : secrets ,
211
212
}
212
213
213
214
externalProvisionerCRB = & rbacv1.ClusterRoleBinding {
214
215
ObjectMeta : metav1.ObjectMeta {
215
- Name : config .GetNameForResource (config .ExternalProvisionerClusterRoleBinding , ibmObjectCSICRName ),
216
+ Name : config .GetNameForResource (config .ExternalProvisionerClusterRoleBinding , config . DriverPrefix ),
216
217
},
217
218
Subjects : []rbacv1.Subject {
218
219
{
219
220
Kind : "ServiceAccount" ,
220
- Name : config .GetNameForResource (config .CSIControllerServiceAccount , ibmObjectCSICRName ),
221
+ Name : config .GetNameForResource (config .CSIControllerServiceAccount , config . DriverPrefix ),
221
222
Namespace : TestNamespace ,
222
223
},
223
224
},
224
225
RoleRef : rbacv1.RoleRef {
225
226
Kind : "ClusterRole" ,
226
- Name : config .GetNameForResource (config .ExternalProvisionerClusterRole , ibmObjectCSICRName ),
227
+ Name : config .GetNameForResource (config .ExternalProvisionerClusterRole , config . DriverPrefix ),
227
228
APIGroup : config .RbacAuthorizationAPIGroup ,
228
229
},
229
230
}
230
231
231
232
controllerSCCCRB = & rbacv1.ClusterRoleBinding {
232
233
ObjectMeta : metav1.ObjectMeta {
233
- Name : config .GetNameForResource (config .CSIControllerSCCClusterRoleBinding , ibmObjectCSICRName ),
234
+ Name : config .GetNameForResource (config .CSIControllerSCCClusterRoleBinding , config . DriverPrefix ),
234
235
},
235
236
Subjects : []rbacv1.Subject {
236
237
{
237
238
Kind : "ServiceAccount" ,
238
- Name : config .GetNameForResource (config .CSIControllerServiceAccount , ibmObjectCSICRName ),
239
+ Name : config .GetNameForResource (config .CSIControllerServiceAccount , config . DriverPrefix ),
239
240
Namespace : TestNamespace ,
240
241
},
241
242
},
242
243
RoleRef : rbacv1.RoleRef {
243
244
Kind : "ClusterRole" ,
244
- Name : config .GetNameForResource (config .CSIControllerSCCClusterRole , ibmObjectCSICRName ),
245
+ Name : config .GetNameForResource (config .CSIControllerSCCClusterRole , config . DriverPrefix ),
245
246
APIGroup : config .RbacAuthorizationAPIGroup ,
246
247
},
247
248
}
248
249
249
250
nodeSCCCRB = & rbacv1.ClusterRoleBinding {
250
251
ObjectMeta : metav1.ObjectMeta {
251
- Name : config .GetNameForResource (config .CSINodeSCCClusterRoleBinding , ibmObjectCSICRName ),
252
+ Name : config .GetNameForResource (config .CSINodeSCCClusterRoleBinding , config . DriverPrefix ),
252
253
},
253
254
Subjects : []rbacv1.Subject {
254
255
{
255
256
Kind : "ServiceAccount" ,
256
- Name : config .GetNameForResource (config .CSINodeServiceAccount , ibmObjectCSICRName ),
257
+ Name : config .GetNameForResource (config .CSINodeServiceAccount , config . DriverPrefix ),
257
258
Namespace : TestNamespace ,
258
259
},
259
260
},
260
261
RoleRef : rbacv1.RoleRef {
261
262
Kind : "ClusterRole" ,
262
- Name : config .GetNameForResource (config .CSINodeSCCClusterRole , ibmObjectCSICRName ),
263
+ Name : config .GetNameForResource (config .CSINodeSCCClusterRole , config . DriverPrefix ),
263
264
APIGroup : config .RbacAuthorizationAPIGroup ,
264
265
},
265
266
}
266
267
267
268
externalProvisionerCR = & rbacv1.ClusterRole {
268
269
ObjectMeta : metav1.ObjectMeta {
269
- Name : config .GetNameForResource (config .ExternalProvisionerClusterRole , ibmObjectCSICRName ),
270
+ Name : config .GetNameForResource (config .ExternalProvisionerClusterRole , config . DriverPrefix ),
270
271
},
271
272
Rules : []rbacv1.PolicyRule {
272
273
{
@@ -309,7 +310,7 @@ var (
309
310
310
311
controllerSCCCR = & rbacv1.ClusterRole {
311
312
ObjectMeta : metav1.ObjectMeta {
312
- Name : config .GetNameForResource (config .CSIControllerSCCClusterRole , ibmObjectCSICRName ),
313
+ Name : config .GetNameForResource (config .CSIControllerSCCClusterRole , config . DriverPrefix ),
313
314
},
314
315
Rules : []rbacv1.PolicyRule {
315
316
{
@@ -323,7 +324,7 @@ var (
323
324
324
325
nodeSCCCR = & rbacv1.ClusterRole {
325
326
ObjectMeta : metav1.ObjectMeta {
326
- Name : config .GetNameForResource (config .CSINodeSCCClusterRole , ibmObjectCSICRName ),
327
+ Name : config .GetNameForResource (config .CSINodeSCCClusterRole , config . DriverPrefix ),
327
328
},
328
329
Rules : []rbacv1.PolicyRule {
329
330
{
@@ -342,10 +343,37 @@ var (
342
343
343
344
rCloneSC = & storagev1.StorageClass {
344
345
ObjectMeta : metav1.ObjectMeta {
345
- Name : config .GetNameForResource ( config . RcloneStorageClass , ibmObjectCSICRName ),
346
+ Name : config .RcloneStorageClass . String ( ),
346
347
},
347
348
Provisioner : config .DriverName ,
348
- ReclaimPolicy : & reclaimPolicy ,
349
+ ReclaimPolicy : & reclaimPolicyDelete ,
350
+ MountOptions : []string {
351
+ "acl=private" ,
352
+ "bucket_acl=private" ,
353
+ "upload_cutoff=256Mi" ,
354
+ "chunk_size=64Mi" ,
355
+ "max_upload_parts=64" ,
356
+ "upload_concurrency=20" ,
357
+ "copy_cutoff=1Gi" ,
358
+ "memory_pool_flush_time=30s" ,
359
+ "disable_checksum=true" ,
360
+ },
361
+ Parameters : map [string ]string {
362
+ "mounter" : "rclone" ,
363
+ "client" : "awss3" ,
364
+ "csi.storage.k8s.io/provisioner-secret-name" : "${pvc.name}" ,
365
+ "csi.storage.k8s.io/provisioner-secret-namespace" : "${pvc.namespace}" ,
366
+ "csi.storage.k8s.io/node-publish-secret-name" : "${pvc.name}" ,
367
+ "csi.storage.k8s.io/node-publish-secret-namespace" : "${pvc.namespace}" ,
368
+ },
369
+ }
370
+
371
+ rCloneRetainSC = & storagev1.StorageClass {
372
+ ObjectMeta : metav1.ObjectMeta {
373
+ Name : config .RcloneRetainStorageClass .String (),
374
+ },
375
+ Provisioner : config .DriverName ,
376
+ ReclaimPolicy : & reclaimPolicyRetain ,
349
377
MountOptions : []string {
350
378
"acl=private" ,
351
379
"bucket_acl=private" ,
@@ -369,10 +397,34 @@ var (
369
397
370
398
s3fsSC = & storagev1.StorageClass {
371
399
ObjectMeta : metav1.ObjectMeta {
372
- Name : config .GetNameForResource (config .S3fsStorageClass , ibmObjectCSICRName ),
400
+ Name : config .S3fsStorageClass .String (),
401
+ },
402
+ Provisioner : config .DriverName ,
403
+ ReclaimPolicy : & reclaimPolicyDelete ,
404
+ MountOptions : []string {
405
+ "multipart_size=62" ,
406
+ "max_dirty_data=51200" ,
407
+ "parallel_count=8" ,
408
+ "max_stat_cache_size=100000" ,
409
+ "retries=5" ,
410
+ "kernel_cache" ,
411
+ },
412
+ Parameters : map [string ]string {
413
+ "mounter" : "s3fs" ,
414
+ "client" : "awss3" ,
415
+ "csi.storage.k8s.io/provisioner-secret-name" : "${pvc.name}" ,
416
+ "csi.storage.k8s.io/provisioner-secret-namespace" : "${pvc.namespace}" ,
417
+ "csi.storage.k8s.io/node-publish-secret-name" : "${pvc.name}" ,
418
+ "csi.storage.k8s.io/node-publish-secret-namespace" : "${pvc.namespace}" ,
419
+ },
420
+ }
421
+
422
+ s3fsRetainSC = & storagev1.StorageClass {
423
+ ObjectMeta : metav1.ObjectMeta {
424
+ Name : config .S3fsRetainStorageClass .String (),
373
425
},
374
426
Provisioner : config .DriverName ,
375
- ReclaimPolicy : & reclaimPolicy ,
427
+ ReclaimPolicy : & reclaimPolicyRetain ,
376
428
MountOptions : []string {
377
429
"multipart_size=62" ,
378
430
"max_dirty_data=51200" ,
@@ -738,7 +790,9 @@ func TestIBMObjectCSIReconcile(t *testing.T) {
738
790
objects : []runtime.Object {
739
791
ibmObjectCSICRWithDeletionTS ,
740
792
rCloneSC ,
793
+ rCloneRetainSC ,
741
794
s3fsSC ,
795
+ s3fsRetainSC ,
742
796
},
743
797
clientFunc : func (objs []runtime.Object ) client.WithWatch {
744
798
return fakedelete .NewClientBuilder ().WithRuntimeObjects (objs ... ).Build ()
0 commit comments