@@ -57,7 +57,6 @@ import (
57
57
crclient "sigs.k8s.io/controller-runtime/pkg/client"
58
58
59
59
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
60
- capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
61
60
"sigs.k8s.io/cluster-api-provider-openstack/test/e2e/shared"
62
61
)
63
62
@@ -898,16 +897,20 @@ func createTestVolumeType(e2eCtx *shared.E2EContext) {
898
897
volumeClient , err := openstack .NewBlockStorageV3 (providerClient , gophercloud.EndpointOpts {Region : clientOpts .RegionName })
899
898
Expect (err ).NotTo (HaveOccurred ())
900
899
901
- shared .Logf ("Creating test volume type" )
902
- _ , err = volumetypes .Create (volumeClient , & volumetypes.CreateOpts {
903
- Name : e2eCtx .E2EConfig .GetVariable (shared .OpenStackVolumeTypeAlt ),
904
- Description : "Test volume type" ,
905
- IsPublic : pointer .Bool (true ),
906
- ExtraSpecs : map [string ]string {},
907
- }).Extract ()
908
- if capoerrors .IsConflict (err ) {
909
- shared .Logf ("Volume type already exists. This may happen in development environments, but it is not expected in CI." )
910
- return
911
- }
912
- Expect (err ).NotTo (HaveOccurred ())
900
+ volumeTypeName := e2eCtx .E2EConfig .GetVariable (shared .OpenStackVolumeTypeAlt )
901
+
902
+ shared .Logf ("Checking if test volume type '%s' exists" , volumeTypeName )
903
+
904
+ err = Eventually (func () error {
905
+ shared .Logf ("Checking if test volume type '%s' exists" , volumeTypeName )
906
+ _ , err := volumetypes .Get (volumeClient , volumeTypeName ).Extract ()
907
+ return err
908
+ }, 30 * time .Second , 5 * time .Second )
909
+
910
+ if err != nil {
911
+ shared .Logf ("Error after retries: %v" , err )
912
+ Expect (err ).NotTo (HaveOccurred ())
913
+ }
914
+
915
+ shared .Logf ("Proceeding with volume type '%s'." , volumeTypeName )
913
916
}
0 commit comments