Skip to content

Commit 05c5cad

Browse files
committed
feat(manager): ✨ add region to openStackMachineSpec.ProviderID field from crd identityRef
To made CAPO compatible with OCCM multi-cloud deployment we need to manage providerID format with region code as introduced [here](kubernetes/cloud-provider-openstack#1900) (`openstack://region/instance_uuid`). Add Region field to OpenStackIdentityReference type to define region name in providerID string. If specified, it overrides any value in clouds.yaml. An empty or undefined Region field permit to be fully backward compatible. Signed-off-by: MatthieuFin <[email protected]>
1 parent 28cccb9 commit 05c5cad

19 files changed

+181
-11
lines changed

api/v1alpha6/conversion_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ func TestFuzzyConversion(t *testing.T) {
9191
}
9292
},
9393

94+
func(identityRef *infrav1.OpenStackIdentityReference, c fuzz.Continue) {
95+
c.FuzzNoCustom(identityRef)
96+
97+
// None of the following identityRef fields have ever been set in v1alpha6
98+
identityRef.Region = ""
99+
},
100+
94101
func(spec *OpenStackMachineSpec, c fuzz.Continue) {
95102
c.FuzzNoCustom(spec)
96103

api/v1alpha6/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/conversion_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ func TestFuzzyConversion(t *testing.T) {
8989
}
9090
}
9191
},
92+
93+
func(identityRef *infrav1.OpenStackIdentityReference, c fuzz.Continue) {
94+
c.FuzzNoCustom(identityRef)
95+
96+
// None of the following identityRef fields have ever been set in v1alpha7
97+
identityRef.Region = ""
98+
},
9299
}
93100

94101
return slices.Concat(v1alpha7FuzzerFuncs, testhelpers.InfraV1FuzzerFuncs())

api/v1alpha7/zz_generated.conversion.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/identity_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1beta1
1818

1919
// OpenStackIdentityReference is a reference to an infrastructure
2020
// provider identity to be used to provision cluster resources.
21+
// +kubebuilder:validation:XValidation:rule="(!has(self.region) && !has(oldSelf.region)) || self.region == oldSelf.region",message="region is immutable"
2122
type OpenStackIdentityReference struct {
2223
// Name is the name of a secret in the same namespace as the resource being provisioned.
2324
// The secret must contain a key named `clouds.yaml` which contains an OpenStack clouds.yaml file.
@@ -28,6 +29,12 @@ type OpenStackIdentityReference struct {
2829
// CloudName specifies the name of the entry in the clouds.yaml file to use.
2930
// +kubebuilder:validation:Required
3031
CloudName string `json:"cloudName"`
32+
33+
// Region specifies an OpenStack region to use. If specified, it overrides
34+
// any value in clouds.yaml. If specified for an OpenStackMachine, its
35+
// value will be included in providerID.
36+
// +optional
37+
Region string `json:"region,omitempty"`
3138
}
3239

3340
// IdentityRefProvider is an interface for obtaining OpenStack credentials from an API object

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackfloatingippools.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachines.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackmachinetemplates.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)