Skip to content

Commit 3e8f67b

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 ProviderIDRegion field to OpenStackIdentityReference type to define region name in providerID string. An empty or undefined ProviderIDRegion field permit to be fully backward compatible. Signed-off-by: MatthieuFin <[email protected]>
1 parent e8bddb5 commit 3e8f67b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

api/v1beta1/identity_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ type OpenStackIdentityReference struct {
2828
// CloudName specifies the name of the entry in the clouds.yaml file to use.
2929
// +kubebuilder:validation:Required
3030
CloudName string `json:"cloudName"`
31+
32+
// ProviderIDRegion specifies the name of the region to specify in providerID field format `openstack://ProviderIDRegion/instance_uuid`.
33+
// This option permit to been compatible with multiple OCCM (one per OS cluster).
34+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="region is immutable"
35+
// +optional
36+
ProviderIDRegion string `json:"providerIDRegion,omitempty"`
3137
}
3238

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

controllers/openstackmachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ func (r *OpenStackMachineReconciler) reconcileMachineState(scope *scope.WithLogg
422422
conditions.MarkTrue(openStackMachine, infrav1.InstanceReadyCondition)
423423

424424
// Set properties required by CAPI machine controller
425-
openStackMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("openstack:///%s", *openStackServer.Status.InstanceID))
425+
openStackMachine.Spec.ProviderID = ptr.To(fmt.Sprintf("openstack://%s/%s", openStackMachine.Spec.IdentityRef.ProviderIDRegion, *openStackServer.Status.InstanceID))
426426
openStackMachine.Status.InstanceID = openStackServer.Status.InstanceID
427427
openStackMachine.Status.Ready = true
428428
case infrav1.InstanceStateError:

0 commit comments

Comments
 (0)