Skip to content

Commit

Permalink
Remove vpc list copy before sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Kovacs committed Feb 5, 2024
1 parent 047ad7b commit 3c2e909
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func (r *LinodeMachineReconciler) reconcile(
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer("")

failureReason := cerrs.MachineStatusError("UnknownError")
//nolint:dupl // Code duplication is simplicity in this case.
defer func() {
if err != nil {
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
Expand Down
9 changes: 3 additions & 6 deletions controller/linodemachine_controller_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,11 @@ func (r *LinodeMachineReconciler) getVPCInterfaceConfig(ctx context.Context, mac
return nil, err
default:
// Place node into the least busy subnet
sortedSubnets := make([]linodego.VPCSubnet, len(vpc.Subnets))
copy(sortedSubnets, vpc.Subnets)

sort.Slice(sortedSubnets, func(i, j int) bool {
return len(sortedSubnets[i].Linodes) > len(sortedSubnets[j].Linodes)
sort.Slice(vpc.Subnets, func(i, j int) bool {
return len(vpc.Subnets[i].Linodes) > len(vpc.Subnets[j].Linodes)
})

subnetID = sortedSubnets[0].ID
subnetID = vpc.Subnets[0].ID
}

return &linodego.InstanceConfigInterfaceCreateOptions{
Expand Down
1 change: 0 additions & 1 deletion controller/linodevpc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (r *LinodeVPCReconciler) reconcile(
vpcScope.LinodeVPC.Status.FailureMessage = util.Pointer("")

failureReason := infrav1.VPCStatusError("UnknownError")
//nolint:dupl // Code duplication is simplicity in this case.
defer func() {
if err != nil {
vpcScope.LinodeVPC.Status.FailureReason = util.Pointer(failureReason)
Expand Down

0 comments on commit 3c2e909

Please sign in to comment.