@@ -24,6 +24,7 @@ import (
24
24
func TestController (t * testing.T ) {
25
25
blockVolumeMode := v1 .PersistentVolumeBlock
26
26
fsVolumeMode := v1 .PersistentVolumeFilesystem
27
+
27
28
for _ , test := range []struct {
28
29
Name string
29
30
PVC * v1.PersistentVolumeClaim
@@ -37,7 +38,8 @@ func TestController(t *testing.T) {
37
38
// is PVC being expanded in-use
38
39
pvcInUse bool
39
40
// does PVC being expanded has Failed Precondition errors
40
- pvcHasInUseErrors bool
41
+ pvcHasInUseErrors bool
42
+ handleVolumeInUseErrorHandler bool
41
43
}{
42
44
{
43
45
Name : "Invalid key" ,
@@ -87,33 +89,66 @@ func TestController(t *testing.T) {
87
89
CallCSIExpand : true ,
88
90
},
89
91
{
90
- Name : "Resize PVC with FS resize" ,
91
- PVC : createPVC (2 , 1 ),
92
- PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
93
- CreateObjects : true ,
94
- NodeResize : true ,
95
- CallCSIExpand : true ,
92
+ Name : "Resize PVC with FS resize" ,
93
+ PVC : createPVC (2 , 1 ),
94
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
95
+ CreateObjects : true ,
96
+ NodeResize : true ,
97
+ CallCSIExpand : true ,
98
+ handleVolumeInUseErrorHandler : true ,
96
99
},
97
100
{
98
- Name : "Block Resize PVC with FS resize" ,
99
- PVC : createPVC (2 , 1 ),
100
- PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & blockVolumeMode ),
101
- CreateObjects : true ,
102
- NodeResize : true ,
103
- CallCSIExpand : true ,
104
- expectBlockVolume : true ,
101
+ Name : "Block Resize PVC with FS resize" ,
102
+ PVC : createPVC (2 , 1 ),
103
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & blockVolumeMode ),
104
+ CreateObjects : true ,
105
+ NodeResize : true ,
106
+ CallCSIExpand : true ,
107
+ expectBlockVolume : true ,
108
+ handleVolumeInUseErrorHandler : true ,
109
+ },
110
+ {
111
+ Name : "Resize PVC, no FS resize, pvc-inuse with failedprecondition" ,
112
+ PVC : createPVC (2 , 1 ),
113
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
114
+ CreateObjects : true ,
115
+ CallCSIExpand : false ,
116
+ pvcHasInUseErrors : true ,
117
+ pvcInUse : true ,
118
+ handleVolumeInUseErrorHandler : true ,
119
+ },
120
+ {
121
+ Name : "Resize PVC, no FS resize, pvc-inuse but no failedprecondition error" ,
122
+ PVC : createPVC (2 , 1 ),
123
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
124
+ CreateObjects : true ,
125
+ CallCSIExpand : true ,
126
+ pvcHasInUseErrors : false ,
127
+ pvcInUse : true ,
128
+ handleVolumeInUseErrorHandler : true ,
129
+ },
130
+ {
131
+ Name : "Resize PVC, no FS resize, pvc not in-use but has failedprecondition error" ,
132
+ PVC : createPVC (2 , 1 ),
133
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
134
+ CreateObjects : true ,
135
+ CallCSIExpand : true ,
136
+ pvcHasInUseErrors : true ,
137
+ pvcInUse : false ,
138
+ handleVolumeInUseErrorHandler : true ,
105
139
},
140
+ // test cases with volume in use error handling disabled.
106
141
{
107
- Name : "Resize PVC, no FS resize, pvc-inuse with failedprecondition" ,
142
+ Name : "Feat disabled, Resize PVC, no FS resize, pvc-inuse with failedprecondition" ,
108
143
PVC : createPVC (2 , 1 ),
109
144
PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
110
145
CreateObjects : true ,
111
- CallCSIExpand : false ,
146
+ CallCSIExpand : true ,
112
147
pvcHasInUseErrors : true ,
113
148
pvcInUse : true ,
114
149
},
115
150
{
116
- Name : "Resize PVC, no FS resize, pvc-inuse but no failedprecondition error" ,
151
+ Name : "Feat disabled, Resize PVC, no FS resize, pvc-inuse but no failedprecondition error" ,
117
152
PVC : createPVC (2 , 1 ),
118
153
PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
119
154
CreateObjects : true ,
@@ -122,14 +157,38 @@ func TestController(t *testing.T) {
122
157
pvcInUse : true ,
123
158
},
124
159
{
125
- Name : "Resize PVC, no FS resize, pvc not in-use but has failedprecondition error" ,
160
+ Name : "Feat disabled, Resize PVC, no FS resize, pvc not in-use but has failedprecondition error" ,
126
161
PVC : createPVC (2 , 1 ),
127
162
PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
128
163
CreateObjects : true ,
129
164
CallCSIExpand : true ,
130
165
pvcHasInUseErrors : true ,
131
166
pvcInUse : false ,
132
167
},
168
+ {
169
+ Name : "Feat disabled, Block Resize PVC with FS resize" ,
170
+ PVC : createPVC (2 , 1 ),
171
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & blockVolumeMode ),
172
+ CreateObjects : true ,
173
+ NodeResize : true ,
174
+ CallCSIExpand : true ,
175
+ expectBlockVolume : true ,
176
+ },
177
+ {
178
+ Name : "Feat disabled, Resize PVC with FS resize" ,
179
+ PVC : createPVC (2 , 1 ),
180
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
181
+ CreateObjects : true ,
182
+ NodeResize : true ,
183
+ CallCSIExpand : true ,
184
+ },
185
+ {
186
+ Name : "Feat disabled, Resize PVC, no FS resize" ,
187
+ PVC : createPVC (2 , 1 ),
188
+ PV : createPV (1 , "testPVC" , defaultNS , "foobar" , & fsVolumeMode ),
189
+ CreateObjects : true ,
190
+ CallCSIExpand : true ,
191
+ },
133
192
} {
134
193
client := csi .NewMockClient ("mock" , test .NodeResize , true , true )
135
194
driverName , _ := client .GetDriverName (context .TODO ())
@@ -163,7 +222,7 @@ func TestController(t *testing.T) {
163
222
t .Fatalf ("Test %s: Unable to create resizer: %v" , test .Name , err )
164
223
}
165
224
166
- controller := NewResizeController (driverName , csiResizer , kubeClient , time .Second , informerFactory , workqueue .DefaultControllerRateLimiter ())
225
+ controller := NewResizeController (driverName , csiResizer , kubeClient , time .Second , informerFactory , workqueue .DefaultControllerRateLimiter (), test . handleVolumeInUseErrorHandler )
167
226
168
227
ctrlInstance , _ := controller .(* resizeController )
169
228
0 commit comments