Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bilbobrovall committed Jan 5, 2024
1 parent 655c789 commit ab6bb87
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,60 +349,60 @@ func (r *OpenStackMachineReconciler) reconcileFloatingAddressFromPool(ctx contex
}
}

if claim.Status.AddressRef.Name != "" {
address := &ipamv1.IPAddress{}
addressKey := client.ObjectKey{Namespace: openStackMachine.Namespace, Name: claim.Status.AddressRef.Name}
if claim.Status.AddressRef.Name == "" {
scope.Logger().Info("Waiting for IPAddressClaim to be allocated", "name", claim.Name)
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(false)
conditions.MarkFalse(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition, infrav1.FloatingAddressFromPoolWaitingForIpamProviderReason, clusterv1.ConditionSeverityWarning, "")
return nil
}

if err := r.Client.Get(ctx, addressKey, address); err != nil {
return err
}
address := &ipamv1.IPAddress{}
addressKey := client.ObjectKey{Namespace: openStackMachine.Namespace, Name: claim.Status.AddressRef.Name}

instanceAddresses := instanceNS.Addresses()
for _, instanceAddress := range instanceAddresses {
if instanceAddress.Address == address.Spec.Address && instanceAddress.Type == corev1.NodeExternalIP {
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(true)
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
return nil
}
}
if err := r.Client.Get(ctx, addressKey, address); err != nil {
return err
}

fip, err := networkingService.GetFloatingIP(address.Spec.Address)
if err != nil {
return err
}
if fip == nil {
conditions.MarkFalse(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition, infrav1.FloatingAddressFromPoolErrorReason, clusterv1.ConditionSeverityError, "floating IP does not exist")
return fmt.Errorf("floating IP %q does not exist", address.Spec.Address)
instanceAddresses := instanceNS.Addresses()
for _, instanceAddress := range instanceAddresses {
if instanceAddress.Address == address.Spec.Address {
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(true)
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
return nil
}
}

port, err := computeService.GetManagementPort(openStackCluster, instanceStatus)
if err != nil {
fip, err := networkingService.GetFloatingIP(address.Spec.Address)
if err != nil {
return err
}
if fip == nil {
conditions.MarkFalse(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition, infrav1.FloatingAddressFromPoolErrorReason, clusterv1.ConditionSeverityError, "floating IP does not exist")
return fmt.Errorf("floating IP %q does not exist", address.Spec.Address)
}

port, err := computeService.GetManagementPort(openStackCluster, instanceStatus)
if err != nil {
return err
}

// Add finalizer to claim to prevent deletion until the floating IP is released
if controllerutil.AddFinalizer(claim, infrav1.IPClaimMachineFinalizer) {
if err := r.Client.Update(ctx, claim); err != nil {
return err
}

// Add finalizer to claim to prevent deletion until the floating IP is released
if controllerutil.AddFinalizer(claim, infrav1.IPClaimMachineFinalizer) {
}
if err = networkingService.AssociateFloatingIP(openStackMachine, fip, port.ID); err != nil {
// Remove finalizer since we failed to associate the floating IP
if controllerutil.RemoveFinalizer(claim, infrav1.IPClaimMachineFinalizer) {
if err := r.Client.Update(ctx, claim); err != nil {
return err
}
}
if err = networkingService.AssociateFloatingIP(openStackMachine, fip, port.ID); err != nil {
// Remove finalizer since we failed to associate the floating IP
if controllerutil.RemoveFinalizer(claim, infrav1.IPClaimMachineFinalizer) {
if err := r.Client.Update(ctx, claim); err != nil {
return err
}
}
return err
}

openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(true)
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
} else {
scope.Logger().Info("Waiting for IPAddressClaim to be allocated", "name", claim.Name)
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(false)
conditions.MarkFalse(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition, infrav1.FloatingAddressFromPoolWaitingForIpamProviderReason, clusterv1.ConditionSeverityWarning, "")
return err
}
openStackMachine.Status.FloatingAddressFromPoolReady = pointer.Bool(true)
conditions.MarkTrue(openStackMachine, infrav1.FloatingAddressFromPoolReadyCondition)
return nil
}

Expand Down

0 comments on commit ab6bb87

Please sign in to comment.