nomad-0005: scheduler/reconciler/reconcile_cluster.go
handleReconnectingAllocs slices.Contains(replacements, alloc.ID)
O(A×R) inner linear scan — replaced with map[string]struct{} O(1)
Also confirm envoy-0001 through envoy-0004 were previously scanned
(UNDF-63, 390, 391, 699) and nomad-0001 through nomad-0004 (UNDF-476..479).
34 lines
1.1 KiB
Diff
34 lines
1.1 KiB
Diff
# UNDF: UNDF-2026-000000748
|
|
--- a/scheduler/reconciler/reconcile_cluster.go
|
|
+++ b/scheduler/reconciler/reconcile_cluster.go
|
|
@@ -1,6 +1,7 @@
|
|
import (
|
|
+ "golang.org/x/exp/maps"
|
|
"golang.org/x/exp/slices"
|
|
)
|
|
|
|
@@ -1310,13 +1310,14 @@ func (a *allocReconciler) handleReconnectingAllocs(...) {
|
|
// A replacement allocation could fail and be replaced with another
|
|
// so follow the replacements in a linked list style
|
|
- replacements := []string{}
|
|
+ replacementsSet := make(map[string]struct{})
|
|
nextAlloc := reconnectingAlloc.NextAllocation
|
|
for {
|
|
val, ok := all[nextAlloc]
|
|
if !ok {
|
|
break
|
|
}
|
|
- replacements = append(replacements, val.ID)
|
|
+ replacementsSet[val.ID] = struct{}{}
|
|
nextAlloc = val.NextAllocation
|
|
}
|
|
|
|
// Find replacement allocations and decide which one to stop.
|
|
for _, replacementAlloc := range all {
|
|
if replacementAlloc == reconnectingAlloc {
|
|
continue
|
|
}
|
|
- if !slices.Contains(replacements, replacementAlloc.ID) || replacementAlloc.ServerTerminalStatus() {
|
|
+ if _, ok := replacementsSet[replacementAlloc.ID]; !ok || replacementAlloc.ServerTerminalStatus() {
|
|
continue
|
|
}
|