fix(controller): sum AdditionalPU from all active schedules for desiredMinPUs#215
Merged
Conversation
…edMinPUs Previously calcDesiredPURange used min() across active schedules for desiredMinPUs, so when schedules with different AdditionalPU values overlapped, only the smallest was applied. This caused the autoscaler to silently ignore larger schedules and even scale down unexpectedly. Change to sum (matching the existing desiredMaxPUs logic) so every active schedule's contribution is counted independently. Also add unit tests for calcDesiredPURange, which had no test coverage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dition Replace the exactlyOneOfBools helper (variadic, general-purpose) with a direct boolean XOR expression. The function only ever had two fields to check, so the generality added no value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rustycl0ck
approved these changes
Apr 21, 2026
|
A tag with version v0.7.1 has been created! 🎉 Changes: v0.7.0...v0.7.1 |
|
A new github release with version v0.7.1 has been created! 🎉 |
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.
What this PR does
calcDesiredPURangeto use sum (instead of min) when computingdesiredMinPUsfrom active schedules, matching the existingdesiredMaxPUslogicexactlyOneOfBoolshelper invalidateTargetCPUUtilizationwith a direct XOR boolean expressionWhy we need it
When multiple
SpannerAutoscaleSchedulewindows overlap,desiredMinPUswas computed by taking the minimumAdditionalPUacross all active schedules. This meant that if a later schedule had a smallerAdditionalPUthan an earlier one, it would overwrite the effective minimum and silently reduce the PU floor — even during the earlier schedule's active window.Example
At 7:20, when both A and B are active:
desiredMinPUs = spec.min + min(5000, 1000) = spec.min + 1000— schedule A's +5,000 is overwritten by B's smaller value, causing an unintended scale-downdesiredMinPUs = spec.min + (5000 + 1000) = spec.min + 6,000— all schedules contribute independentlydesiredMaxPUsalready used sum and is unchanged. Users who avoided overlapping schedule windows as a workaround are unaffected.Test plan
calcDesiredPURange(no schedules, single schedule, overlapping schedules, rounding, no-change detection)make testpasses🤖 Generated with Claude Code