Skip to content

Commit 3c9c3ca

Browse files
author
Max Rantil
committed
Make it able to bring your own OpenStack volume
Signed-off-by: Max Rantil <[email protected]>
1 parent 141013b commit 3c9c3ca

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

hack/ci/cloud-init/controller.yaml.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
openstack aggregate add host "$aggregateid" "$host"
151151
done
152152

153+
# Create volume type
154+
openstack volume type create --description "Test volume type" --public "test-volume-type"
155+
153156
# the flavors are created in a way that we can execute at least 2 e2e tests in parallel (overall we have 32 vCPUs)
154157
openstack flavor delete m1.tiny
155158
openstack flavor create --ram 512 --disk 1 --ephemeral 1 --vcpus 1 --public --id 1 m1.tiny --property hw_rng:allowed='True'

test/e2e/suites/e2e/e2e_test.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import (
5757
crclient "sigs.k8s.io/controller-runtime/pkg/client"
5858

5959
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha7"
60-
capoerrors "sigs.k8s.io/cluster-api-provider-openstack/pkg/utils/errors"
6160
"sigs.k8s.io/cluster-api-provider-openstack/test/e2e/shared"
6261
)
6362

@@ -898,16 +897,20 @@ func createTestVolumeType(e2eCtx *shared.E2EContext) {
898897
volumeClient, err := openstack.NewBlockStorageV3(providerClient, gophercloud.EndpointOpts{Region: clientOpts.RegionName})
899898
Expect(err).NotTo(HaveOccurred())
900899

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)
913916
}

0 commit comments

Comments
 (0)