Skip to content

Commit 513dd29

Browse files
committed
fix: (azure)machinepools: stop continuous reconciliation of resources by sorting ProviderIDs
1 parent 8f05062 commit 513dd29

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

azure/scope/machinepool.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"encoding/base64"
2222
"encoding/json"
2323
"fmt"
24+
"slices"
2425
"strings"
2526

2627
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2"
@@ -357,6 +358,9 @@ func (m *MachinePoolScope) updateReplicasAndProviderIDs(ctx context.Context) err
357358
providerIDs[i] = machine.Spec.ProviderID
358359
}
359360

361+
// Sort providerIDs to ensure deterministic ordering to prevent continuous reconciliation.
362+
slices.Sort(providerIDs)
363+
360364
m.AzureMachinePool.Status.Replicas = readyReplicas
361365
m.AzureMachinePool.Spec.ProviderIDList = providerIDs
362366
return nil

controllers/azuremanagedmachinepool_reconciler.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22+
"slices"
2223
"time"
2324

2425
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5"
@@ -164,6 +165,8 @@ func (s *azureManagedMachinePoolService) Reconcile(ctx context.Context) error {
164165
providerIDs[i] = providerID
165166
}
166167

168+
// Sort providerIDs to ensure deterministic ordering to prevent continuous reconciliation.
169+
slices.Sort(providerIDs)
167170
s.scope.SetAgentPoolProviderIDList(providerIDs)
168171
s.scope.SetAgentPoolReplicas(int32(len(providerIDs)))
169172
s.scope.SetAgentPoolReady(true)

0 commit comments

Comments
 (0)