Skip to content

Commit 0b716f2

Browse files
authored
fix: avoid duplicate pod reconciliations (#179)
Fixes an issue where multiple ephemeral, duplicate pods could be created during the reconciliation process. Closes: RHAIENG-1544 Approved-by: nathan-weinberg
1 parent b0b5d93 commit 0b716f2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/deploy/kustomizer.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"path/filepath"
99
"slices"
10+
"sort"
1011

1112
llamav1alpha1 "github.com/llamastack/llama-stack-k8s-operator/api/v1alpha1"
1213
"github.com/llamastack/llama-stack-k8s-operator/pkg/compare"
@@ -424,9 +425,16 @@ func updateDeploymentSpec(res *resource.Resource, manifestCtx *ManifestContext)
424425
}
425426

426427
// Apply pod spec enhancements
428+
// Sort keys to ensure deterministic ordering and prevent spurious deployment updates
427429
if manifestCtx.PodSpec != nil {
428-
for key, value := range manifestCtx.PodSpec {
429-
templateSpec[key] = value
430+
keys := make([]string, 0, len(manifestCtx.PodSpec))
431+
for key := range manifestCtx.PodSpec {
432+
keys = append(keys, key)
433+
}
434+
sort.Strings(keys)
435+
436+
for _, key := range keys {
437+
templateSpec[key] = manifestCtx.PodSpec[key]
430438
}
431439
}
432440

0 commit comments

Comments
 (0)