Skip to content

Fix placement bugs and cache CEL programs#47

Merged
ArnobKumarSaha merged 6 commits into
masterfrom
anti
Jun 1, 2026
Merged

Fix placement bugs and cache CEL programs#47
ArnobKumarSaha merged 6 commits into
masterfrom
anti

Conversation

@ArnobKumarSaha

@ArnobKumarSaha ArnobKumarSaha commented May 22, 2026

Copy link
Copy Markdown
Member
  • TSC duplication on WhenUnsatisfiable flipUpsertTopologySpreadConstraint now matches on TopologyKey alone. Previously, flipping DoNotScheduleScheduleAnyway for the same key appended a second constraint instead of replacing it.
  • Pod double-count in getAppropriateDomainIndex — inner break only escaped the innermost loop, so a pod with multiple NodeSelectorTerms (or multiple preferred terms) was counted multiple times against alreadyAssigned. Extracted countPodForTopology / countPodForPreferredTopology helpers that return after the first match per pod.
  • Silent rule loss on duplicate TopologyKeysetNodeAffinityFromPlacement now logs klog.Warningf when two DoNotSchedule rules share a TopologyKey (still upserts; the second rule overwrites the first).
  • CEL int assertion too narrowevaluateCEL now accepts int64, int, int32, uint64 returns.
  • CEL recompilation per evaluation — compiled cel.Programs are now cached per PodInfo in programCache, populated in preCalc.
  • Noisy logging — per-reconcile klog.Infof dumps dropped to klog.V(4).Infof.
  • Error wrappingpreCalc, evaluateCEL, and getAppropriateDomainIndex errors now use %w and include the placement policy name.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
UpsertTopologySpreadConstraint now matches on TopologyKey alone.
Flipping DoNotSchedule <-> ScheduleAnyway for the same key was
appending a second constraint instead of replacing the existing one.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
Silent rule loss when two DoNotSchedule rules share a TopologyKey;
now logs klog.Warningf so operators can detect misconfigured policies.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
The inner break only escaped the innermost loop, so a pod with multiple
NodeSelectorTerms or preferred terms was counted multiple times against
alreadyAssigned. Extracted countPodForTopology and
countPodForPreferredTopology helpers that return after the first match
per pod.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
Errors now use %w and include the placement policy name or operation,
making failures easier to trace without reading source.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
CEL compile+check+program was called on every evaluateCEL invocation.
Compiled cel.Programs are now cached per PodInfo in programCache,
initialized in preCalc, keyed by rule expression string.

evaluateCEL signature changed to (*PodInfo, rule); errors now use %w.
Type assertion widened to accept int64, int, int32, uint64 returns.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
@ArnobKumarSaha ArnobKumarSaha merged commit e054003 into master Jun 1, 2026
4 checks passed
@ArnobKumarSaha ArnobKumarSaha deleted the anti branch June 1, 2026 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant