@@ -104,7 +104,7 @@ var _ = utils.SIGDescribe("Volume expand", func() {
104
104
framework .ExpectError (err , "While updating non-expandable PVC" )
105
105
})
106
106
107
- ginkgo .It ("Verify if editing PVC allows resize " , func () {
107
+ ginkgo .It ("Verify if offline PVC expansion works " , func () {
108
108
pvc , storageClassVar , err = setupFunc (true /* allowExpansion */ , false /*BlockVolume*/ )
109
109
framework .ExpectNoError (err , "Error creating non-expandable PVC" )
110
110
@@ -122,6 +122,11 @@ var _ = utils.SIGDescribe("Volume expand", func() {
122
122
framework .ExpectNoError (err , "while cleaning up pod already deleted in resize test" )
123
123
}()
124
124
125
+ ginkgo .By ("Deleting the previously created pod" )
126
+ err = framework .DeletePodWithWait (f , c , pod )
127
+ framework .ExpectNoError (err , "while deleting pod for resizing" )
128
+
129
+ // We expand the PVC while no pod is using it to ensure offline expansion
125
130
ginkgo .By ("Expanding current pvc" )
126
131
newSize := resource .MustParse ("6Gi" )
127
132
pvc , err = expandPVCSize (pvc , newSize , c )
@@ -145,10 +150,6 @@ var _ = utils.SIGDescribe("Volume expand", func() {
145
150
gomega .Expect (len (inProgressConditions )).To (gomega .Equal (1 ), "pvc must have file system resize pending condition" )
146
151
gomega .Expect (inProgressConditions [0 ].Type ).To (gomega .Equal (v1 .PersistentVolumeClaimFileSystemResizePending ), "pvc must have fs resizing condition" )
147
152
148
- ginkgo .By ("Deleting the previously created pod" )
149
- err = framework .DeletePodWithWait (f , c , pod )
150
- framework .ExpectNoError (err , "while deleting pod for resizing" )
151
-
152
153
ginkgo .By ("Creating a new pod with same volume" )
153
154
pod2 , err := framework .CreatePod (c , ns , nil , pvcClaims , false , "" )
154
155
framework .ExpectNoError (err , "while recreating pod for resizing" )
@@ -165,6 +166,48 @@ var _ = utils.SIGDescribe("Volume expand", func() {
165
166
gomega .Expect (len (pvcConditions )).To (gomega .Equal (0 ), "pvc should not have conditions" )
166
167
})
167
168
169
+ ginkgo .It ("should resize volume when PVC is edited while pod is using it" , func () {
170
+ pvc , storageClassVar , err = setupFunc (true /* allowExpansion */ , false /*BlockVolume*/ )
171
+ framework .ExpectNoError (err , "Error creating non-expandable PVC" )
172
+
173
+ ginkgo .By ("Waiting for pvc to be in bound phase" )
174
+ pvcClaims := []* v1.PersistentVolumeClaim {pvc }
175
+ pvs , err := framework .WaitForPVClaimBoundPhase (c , pvcClaims , framework .ClaimProvisionTimeout )
176
+ framework .ExpectNoError (err , "Failed waiting for PVC to be bound %v" , err )
177
+ gomega .Expect (len (pvs )).To (gomega .Equal (1 ))
178
+
179
+ ginkgo .By ("Creating a pod with dynamically provisioned volume" )
180
+ pod , err := framework .CreatePod (c , ns , nil , pvcClaims , false , "" )
181
+ framework .ExpectNoError (err , "While creating pods for resizing" )
182
+ defer func () {
183
+ err = framework .DeletePodWithWait (f , c , pod )
184
+ framework .ExpectNoError (err , "while cleaning up pod already deleted in resize test" )
185
+ }()
186
+
187
+ // We expand the PVC while no pod is using it to ensure online expansion
188
+ ginkgo .By ("Expanding current pvc" )
189
+ newSize := resource .MustParse ("6Gi" )
190
+ pvc , err = expandPVCSize (pvc , newSize , c )
191
+ framework .ExpectNoError (err , "While updating pvc for more size" )
192
+ gomega .Expect (pvc ).NotTo (gomega .BeNil ())
193
+
194
+ pvcSize := pvc .Spec .Resources .Requests [v1 .ResourceStorage ]
195
+ if pvcSize .Cmp (newSize ) != 0 {
196
+ framework .Failf ("error updating pvc size %q" , pvc .Name )
197
+ }
198
+
199
+ ginkgo .By ("Waiting for cloudprovider resize to finish" )
200
+ err = waitForControllerVolumeResize (pvc , c , totalResizeWaitPeriod )
201
+ framework .ExpectNoError (err , "While waiting for pvc resize to finish" )
202
+
203
+ ginkgo .By ("Waiting for file system resize to finish" )
204
+ pvc , err = waitForFSResize (pvc , c )
205
+ framework .ExpectNoError (err , "while waiting for fs resize to finish" )
206
+
207
+ pvcConditions := pvc .Status .Conditions
208
+ gomega .Expect (len (pvcConditions )).To (gomega .Equal (0 ), "pvc should not have conditions" )
209
+ })
210
+
168
211
ginkgo .It ("should allow expansion of block volumes" , func () {
169
212
pvc , storageClassVar , err = setupFunc (true /*allowExpansion*/ , true /*blockVolume*/ )
170
213
0 commit comments