@@ -25,6 +25,7 @@ import (
25
25
"github.com/onsi/gomega"
26
26
27
27
v1 "k8s.io/api/core/v1"
28
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
28
29
"k8s.io/apimachinery/pkg/api/resource"
29
30
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
30
31
"k8s.io/apimachinery/pkg/util/errors"
@@ -157,6 +158,24 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
157
158
ginkgo .DeferCleanup (cleanup )
158
159
159
160
var err error
161
+ // create Pod with pvc
162
+ ginkgo .By ("Creating a pod with PVC" )
163
+ podConfig := e2epod.Config {
164
+ NS : f .Namespace .Name ,
165
+ PVCs : []* v1.PersistentVolumeClaim {l .resource .Pvc },
166
+ SeLinuxLabel : e2epod .GetLinuxLabel (),
167
+ NodeSelection : l .config .ClientNodeSelection ,
168
+ ImageID : e2epod .GetDefaultTestImageID (),
169
+ }
170
+ l .pod , err = e2epod .CreateSecPodWithNodeSelection (ctx , f .ClientSet , & podConfig , f .Timeouts .PodStart )
171
+ ginkgo .DeferCleanup (e2epod .DeletePodWithWait , f .ClientSet , l .pod )
172
+ framework .ExpectNoError (err , "While creating pods for expanding" )
173
+
174
+ // Waiting for pod to run
175
+ ginkgo .By ("Waiting for pod to run" )
176
+ err = e2epod .WaitTimeoutForPodRunningInNamespace (ctx , f .ClientSet , l .pod .Name , l .pod .Namespace , f .Timeouts .PodStart )
177
+ framework .ExpectNoError (err )
178
+
160
179
gomega .Expect (l .resource .Sc .AllowVolumeExpansion ).NotTo (gomega .BeNil ())
161
180
allowVolumeExpansion := * l .resource .Sc .AllowVolumeExpansion
162
181
gomega .Expect (allowVolumeExpansion ).To (gomega .BeFalse ())
@@ -166,7 +185,7 @@ func (v *volumeExpandTestSuite) DefineTests(driver storageframework.TestDriver,
166
185
newSize .Add (resource .MustParse ("1Gi" ))
167
186
framework .Logf ("currentPvcSize %v, newSize %v" , currentPvcSize , newSize )
168
187
_ , err = ExpandPVCSize (ctx , l .resource .Pvc , newSize , f .ClientSet )
169
- framework . ExpectError (err , "While updating non-expandable PVC" )
188
+ gomega . Expect (err ). To ( gomega . MatchError ( apierrors . IsForbidden , "While updating non-expandable PVC" ) )
170
189
})
171
190
} else {
172
191
ginkgo .It ("Verify if offline PVC expansion works" , func (ctx context.Context ) {
@@ -316,7 +335,7 @@ func ExpandPVCSize(ctx context.Context, origPVC *v1.PersistentVolumeClaim, size
316
335
return true , nil
317
336
})
318
337
if wait .Interrupted (waitErr ) {
319
- return nil , fmt .Errorf ("timed out attempting to update PVC size. last update error: %v " , lastUpdateError )
338
+ return nil , fmt .Errorf ("timed out attempting to update PVC size. last update error: %w " , lastUpdateError )
320
339
}
321
340
if waitErr != nil {
322
341
return nil , fmt .Errorf ("failed to expand PVC size (check logs for error): %v" , waitErr )
0 commit comments