Skip to content

YARN-12022. Fix CapacityOverTimePolicy rejecting reservations and updates within the quota - #8815

Open
joseluisll wants to merge 1 commit into
apache:trunkfrom
joseluisll:YARN-12022-upstream
Open

joseluisll wants to merge 1 commit into
apache:trunkfrom
joseluisll:YARN-12022-upstream

Conversation

@joseluisll

Copy link
Copy Markdown
Contributor

Description of PR

CapacityOverTimePolicy#validate rejects reservations that are well within the user's average and instantaneous limits. There are two causes:

  1. Integral overflow when an allocation is open at the end of the window. The user's consumption is read with getRangeOverlapping(checkStart, checkEnd). This keeps the start of an allocation that is still in progress at checkEnd, but not its end. The merged view went up to Long.MAX_VALUE, so that allocation stayed open until Long.MAX_VALUE and the integral computation overflowed. This happens when the user has an allocation in progress at the end of the checked window (reservation end + validity window), or a periodic allocation that crosses the period boundary.

    Fix: end the merge at checkEnd + validWindow instead of Long.MAX_VALUE. Only the integral over [checkStart, checkEnd] is checked, and it depends only on points up to the time it is evaluated at. So the check is the same as before in that range, without the overflow. Ending the merge at checkEnd would not work: it adds a point inside the checked range, where the approximated integral overestimates the window and could still reject reservations within the quota. A code comment explains this.

  2. Old version counted twice on update. InMemoryPlan#updateReservation validates the new version while the old one is still in the plan, so the user's consumption already includes it. validate then merged the old version in again with RLEOperator.add instead of removing it, and updates well within the average limit were rejected. Fix: use RLEOperator.subtract. This matches the existing comment above that code and what availableResources() already does.

How was this patch tested?

Three new tests in TestCapacityOverTimePolicy, each of which fails without the fix:

  • testUserAllocationInProgressAtEndOfCheckedWindow: a reservation within the quota is accepted while the user has an allocation in progress past the checked window.
  • testPeriodicAllocationCrossingPeriodBoundary: same, with a periodic allocation that crosses the period boundary.
  • testUpdateReservationWithinQuota: an update within the quota is accepted, and an update over the limit is still rejected with PlanningQuotaException.

The existing TestCapacityOverTimePolicy and reservation tests pass.

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint declared according to the connector-specific documentation? (N/A)
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0? (N/A, no new dependencies)
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files? (N/A)

AI Tooling

Contains content generated by Claude Code.

…ns within the quota.

CapacityOverTimePolicy#validate rejects reservations that are far within
the average and instantaneous limits when the user has an allocation in
progress at the end of the checked window (the reservation end plus the
validity window), or a periodic allocation crossing the period boundary.
The allocation is then open-ended up to Long.MAX_VALUE in the merged
view, which overflows the integral computation.

These tests reproduce the issue and fail until it is fixed.

Do not merge the CapacityOverTimePolicy integral view up to Long.MAX_VALUE.

CapacityOverTimePolicy#validate merged the user consumption and the
reservation over [Long.MIN_VALUE, Long.MAX_VALUE]. The consumption is
taken with getRangeOverlapping(checkStart, checkEnd), which keeps the
start of an allocation in progress at checkEnd but not its end, so that
allocation extended to Long.MAX_VALUE. Computing the integral up to
there overflowed, and reservations far within the quota were rejected.

End the merge at checkEnd + validWindow instead. The integral is only
checked over [checkStart, checkEnd], and it only depends on points up
to the time it is evaluated at, so the check is unchanged in that range
except for the overflow. Ending the merge at checkEnd instead would add
a point there, where the integral approximation overestimates the
window and could reject reservations within the quota.

Explain why CapacityOverTimePolicy ends the merge after checkEnd.

Ending the merge of the integral view at checkEnd would add a point inside
the checked range, where the approximated integral overestimates the
window. Say so next to the code rather than only in the commit history.

Add a test for CapacityOverTimePolicy rejecting updates within the quota.

InMemoryPlan#updateReservation validates the new version of a reservation
while the old version is still in the plan, so the user's consumption
already includes it. CapacityOverTimePolicy#validate then adds the old
version again instead of subtracting it, and updates far within the
average limit are rejected.

The test fails until this is fixed. It also checks that an update over
the limit is still rejected.

Subtract the old version of an updated reservation in CapacityOverTimePolicy.

InMemoryPlan#updateReservation validates the new version of a reservation
while the old version is still in the plan, so the user's consumption
already includes it. CapacityOverTimePolicy#validate merged the old version
into that consumption with RLEOperator.add, counting it twice, so updates
far within the average limit were rejected. Subtract it instead, as the
comment above says and as availableResources() already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 2s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 52m 28s trunk passed
+1 💚 compile 1m 24s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 1m 25s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 1m 19s trunk passed
+1 💚 mvnsite 1m 29s trunk passed
+1 💚 javadoc 1m 11s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 1m 10s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 2m 40s trunk passed
+1 💚 shadedclient 38m 27s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 11s the patch passed
+1 💚 compile 1m 15s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 1m 15s the patch passed
+1 💚 compile 1m 10s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 1m 10s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 2s the patch passed
+1 💚 mvnsite 1m 19s the patch passed
+1 💚 javadoc 0m 50s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 51s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 2m 56s the patch passed
+1 💚 shadedclient 37m 18s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 117m 24s hadoop-yarn-server-resourcemanager in the patch passed.
+1 💚 asflicense 0m 38s The patch does not generate ASF License warnings.
268m 29s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/1/artifact/out/Dockerfile
GITHUB PR #8815
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 1d5687abd480 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 4a7d4ef
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/1/testReport/
Max. process+thread count 938 (vs. ulimit of 10000)
modules C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 57s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 49m 57s trunk passed
+1 💚 compile 1m 25s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 1m 28s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 1m 24s trunk passed
+1 💚 mvnsite 1m 32s trunk passed
+1 💚 javadoc 1m 16s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 1m 14s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 2m 40s trunk passed
+1 💚 shadedclient 35m 45s branch has no errors when building and testing our client artifacts.
-0 ⚠️ patch 36m 21s Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 1s the patch passed
+1 💚 compile 0m 56s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 0m 56s the patch passed
+1 💚 compile 0m 59s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 0m 59s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 55s the patch passed
+1 💚 mvnsite 1m 5s the patch passed
+1 💚 javadoc 0m 45s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 45s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 2m 21s the patch passed
+1 💚 shadedclient 34m 57s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 120m 8s hadoop-yarn-server-resourcemanager in the patch passed.
+1 💚 asflicense 0m 39s The patch does not generate ASF License warnings.
262m 23s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/2/artifact/out/Dockerfile
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux c1a4868026f0 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 86e6c20
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/2/testReport/
Max. process+thread count 904 (vs. ulimit of 10000)
modules C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8815/2/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants