Fix placement bugs and cache CEL programs#47
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WhenUnsatisfiableflip —UpsertTopologySpreadConstraintnow matches onTopologyKeyalone. Previously, flippingDoNotSchedule↔ScheduleAnywayfor the same key appended a second constraint instead of replacing it.getAppropriateDomainIndex— innerbreakonly escaped the innermost loop, so a pod with multipleNodeSelectorTerms(or multiple preferred terms) was counted multiple times againstalreadyAssigned. ExtractedcountPodForTopology/countPodForPreferredTopologyhelpers thatreturnafter the first match per pod.TopologyKey—setNodeAffinityFromPlacementnow logsklog.Warningfwhen twoDoNotSchedulerules share aTopologyKey(still upserts; the second rule overwrites the first).evaluateCELnow acceptsint64,int,int32,uint64returns.cel.Programs are now cached perPodInfoinprogramCache, populated inpreCalc.klog.Infofdumps dropped toklog.V(4).Infof.preCalc,evaluateCEL, andgetAppropriateDomainIndexerrors now use%wand include the placement policy name.