Skip to content

Commit f5a9494

Browse files
committed
Add conversions to make tests pass
1 parent bb3a264 commit f5a9494

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

api/v1alpha6/conversion.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ func restorev1alpha7MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *inf
6565
// We restore the whole Ports since they are anyway immutable.
6666
dst.Ports = previous.Ports
6767
dst.AdditionalBlockDevices = previous.AdditionalBlockDevices
68+
dst.FloatingAddressFromPool = previous.FloatingAddressFromPool
69+
}
70+
71+
func restorev1alpha7MachineStatus(previous *infrav1.OpenStackMachineStatus, dst *infrav1.OpenStackMachineStatus) {
72+
dst.FloatingAddressFromPoolReady = previous.FloatingAddressFromPoolReady
6873
}
6974

7075
func restorev1alpha7Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
@@ -265,6 +270,12 @@ var v1alpha7OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
265270
},
266271
RestoreField: restorev1alpha7MachineSpec,
267272
},
273+
"status": conversion.HashedFieldRestorer[*infrav1.OpenStackMachine, infrav1.OpenStackMachineStatus]{
274+
GetField: func(c *infrav1.OpenStackMachine) *infrav1.OpenStackMachineStatus {
275+
return &c.Status
276+
},
277+
RestoreField: restorev1alpha7MachineStatus,
278+
},
268279
}
269280

270281
func (r *OpenStackMachine) ConvertTo(dstRaw ctrlconversion.Hub) error {

api/v1alpha7/openstackmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type OpenStackMachineStatus struct {
109109

110110
// FloatingAddressFromPoolReady is true when the FloatingIP is ready.
111111
// +optional
112-
FloatingAddressFromPoolReady bool `json:"floatingAddressFromPoolReady"`
112+
FloatingAddressFromPoolReady *bool `json:"floatingAddressFromPoolReady,omitempty"`
113113

114114
// Addresses contains the OpenStack instance associated addresses.
115115
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`

api/v1alpha7/zz_generated.deepcopy.go

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

controllers/openstackmachine_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (r *OpenStackMachineReconciler) reconcileDelete(scope scope.Scope, cluster
303303
func (r *OpenStackMachineReconciler) reconcileFloatingAddressFromPool(ctx context.Context, scope scope.Scope, openStackMachine *infrav1.OpenStackMachine, openStackCluster *infrav1.OpenStackCluster, instanceStatus *compute.InstanceStatus, instanceNS *compute.InstanceNetworkStatus) error {
304304
if openStackMachine.Spec.FloatingAddressFromPool == nil {
305305
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
306-
openStackMachine.Status.FloatingAddressFromPoolReady = true
306+
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.BoolPtr(true)
307307
return nil
308308
}
309309

@@ -362,7 +362,7 @@ func (r *OpenStackMachineReconciler) reconcileFloatingAddressFromPool(ctx contex
362362
instanceAddresses := instanceNS.Addresses()
363363
for _, instanceAddress := range instanceAddresses {
364364
if instanceAddress.Address == address.Spec.Address {
365-
openStackMachine.Status.FloatingAddressFromPoolReady = true
365+
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.BoolPtr(true)
366366
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
367367
return nil
368368
}
@@ -391,11 +391,11 @@ func (r *OpenStackMachineReconciler) reconcileFloatingAddressFromPool(ctx contex
391391
return err
392392
}
393393
}
394-
openStackMachine.Status.FloatingAddressFromPoolReady = true
394+
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.BoolPtr(true)
395395
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
396396
} else {
397397
scope.Logger().Info("Waiting for IPAddressClaim to be allocated", "name", claim.Name)
398-
openStackMachine.Status.FloatingAddressFromPoolReady = false
398+
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.BoolPtr(false)
399399
conditions.MarkFalse(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition, infrav1.FloatingAddressFromPoolWaitingForIpamProviderReason, clusterv1.ConditionSeverityWarning, "")
400400
}
401401
return nil
@@ -496,7 +496,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
496496

497497
switch instanceStatus.State() {
498498
case infrav1.InstanceStateActive:
499-
if openStackMachine.Status.FloatingAddressFromPoolReady {
499+
if pointer.BoolDeref(openStackMachine.Status.FloatingAddressFromPoolReady, false) {
500500
scope.Logger().Info("Machine instance state is ACTIVE", "id", instanceStatus.ID())
501501
conditions.MarkTrue(openStackMachine, infrav1.InstanceReadyCondition)
502502
} else {

0 commit comments

Comments
 (0)