Skip to content

Commit d0e4224

Browse files
committed
Fix lint
1 parent aabd9b3 commit d0e4224

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

internal/controller/linodemachine_controller.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ func (r *LinodeMachineReconciler) reconcilePreflightReady(ctx context.Context, i
717717
return ctrl.Result{}, nil
718718
}
719719

720+
//nolint:cyclop // making it simpler complicates things more
720721
func (r *LinodeMachineReconciler) reconcileUpdate(ctx context.Context, logger logr.Logger, machineScope *scope.MachineScope) (ctrl.Result, error) {
721722
logger.Info("updating machine")
722723
instanceID, err := util.GetInstanceID(machineScope.LinodeMachine.Spec.ProviderID)
@@ -771,6 +772,23 @@ func (r *LinodeMachineReconciler) reconcileUpdate(ctx context.Context, logger lo
771772
return ctrl.Result{RequeueAfter: reconciler.DefaultMachineControllerWaitForRunningDelay}, nil
772773
}
773774
}
775+
776+
res, err := r.reconcileFirewallID(ctx, logger, machineScope)
777+
if err != nil || !res.IsZero() {
778+
return res, err
779+
}
780+
781+
// Clean up bootstrap data after instance creation.
782+
if linodeInstance.Status == linodego.InstanceRunning && machineScope.Machine.Status.Phase == "Running" {
783+
if err := deleteBootstrapData(ctx, machineScope); err != nil {
784+
logger.Error(err, "Fail to delete bootstrap data")
785+
}
786+
}
787+
788+
return ctrl.Result{}, nil
789+
}
790+
791+
func (r *LinodeMachineReconciler) reconcileFirewallID(ctx context.Context, logger logr.Logger, machineScope *scope.MachineScope) (ctrl.Result, error) {
774792
// get the instance's firewalls
775793
firewalls, err := machineScope.LinodeClient.ListInstanceFirewalls(ctx, instanceID, nil)
776794
if err != nil {
@@ -799,18 +817,10 @@ func (r *LinodeMachineReconciler) reconcileUpdate(ctx context.Context, logger lo
799817
)
800818
if err != nil {
801819
logger.Error(err, "Failed to update firewalls for Linode instance")
802-
return ctrl.Result{RequeueAfter: reconciler.DefaultMachineControllerWaitForRunningDelay}, nil
820+
return nil, err
803821
}
804822
}
805-
806-
// Clean up bootstrap data after instance creation.
807-
if linodeInstance.Status == linodego.InstanceRunning && machineScope.Machine.Status.Phase == "Running" {
808-
if err := deleteBootstrapData(ctx, machineScope); err != nil {
809-
logger.Error(err, "Fail to delete bootstrap data")
810-
}
811-
}
812-
813-
return ctrl.Result{}, nil
823+
return nil, nil
814824
}
815825

816826
func (r *LinodeMachineReconciler) reconcileDelete(

0 commit comments

Comments
 (0)