Skip to content

Commit a2e3709

Browse files
committed
Add conversions to make tests pass
1 parent bbc3880 commit a2e3709

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
@@ -61,6 +61,11 @@ func restorev1alpha7MachineSpec(previous *infrav1.OpenStackMachineSpec, dst *inf
6161
// We restore the whole Ports since they are anyway immutable.
6262
dst.Ports = previous.Ports
6363
dst.AdditionalBlockDevices = previous.AdditionalBlockDevices
64+
dst.FloatingAddressFromPool = previous.FloatingAddressFromPool
65+
}
66+
67+
func restorev1alpha7MachineStatus(previous *infrav1.OpenStackMachineStatus, dst *infrav1.OpenStackMachineStatus) {
68+
dst.FloatingAddressFromPoolReady = previous.FloatingAddressFromPoolReady
6469
}
6570

6671
func restorev1alpha7Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
@@ -261,6 +266,12 @@ var v1alpha7OpenStackMachineRestorer = conversion.RestorerFor[*infrav1.OpenStack
261266
},
262267
RestoreField: restorev1alpha7MachineSpec,
263268
},
269+
"status": conversion.HashedFieldRestorer[*infrav1.OpenStackMachine, infrav1.OpenStackMachineStatus]{
270+
GetField: func(c *infrav1.OpenStackMachine) *infrav1.OpenStackMachineStatus {
271+
return &c.Status
272+
},
273+
RestoreField: restorev1alpha7MachineStatus,
274+
},
264275
}
265276

266277
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
@@ -113,7 +113,7 @@ type OpenStackMachineStatus struct {
113113

114114
// FloatingAddressFromPoolReady is true when the FloatingIP is ready.
115115
// +optional
116-
FloatingAddressFromPoolReady bool `json:"floatingAddressFromPoolReady"`
116+
FloatingAddressFromPoolReady *bool `json:"floatingAddressFromPoolReady,omitempty"`
117117

118118
// Addresses contains the OpenStack instance associated addresses.
119119
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)