Skip to content

Commit 0d33307

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

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

azure/scope/machinepool.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
"encoding/base64"
2222
"encoding/json"
2323
"fmt"
24+
25+
"io"
26+
"slices"
2427
"strings"
2528

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

363+
// Sort providerIDs to ensure deterministic ordering to prevent continuous reconciliation.
364+
slices.Sort(providerIDs)
365+
360366
m.AzureMachinePool.Status.Replicas = readyReplicas
361367
m.AzureMachinePool.Spec.ProviderIDList = providerIDs
362368
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)