Repository navigation
Add Neutron quota reservations query and order GetQuotas - #13
Merged
Mohammed Naser (mnaser) merged 1 commit intoDec 4, 2026
Merged
Conversation
This was referenced Dec 3, 2026
Mohammed Naser (mnaser)
requested changes
Dec 3, 2026
Mohammed Naser (mnaser)
left a comment
Member
There was a problem hiding this comment.
The code itself looks great—GetReservationsForResources using UTC_TIMESTAMP() on the database clock and sqlc.slice('resources'), deterministic ORDER BY on GetQuotas, consistent empty-string owner handling across all three Neutron quota queries, and keeping README.md concise with detailed docs in API.md all fit the repo cleanly.
Just housekeeping before we run CI and merge:
- Update the PR title and description to match the final code: the title is currently the raw branch name (
Contrib/neutron 2b4), and the description still describes commit 1 (GetActiveReservationsByProject) and claims a breaking change excluding emptyproject_idrecords fromGetResourceCountsByProject—which commit 2 reverted so empty-string owners are preserved. - Squash the two commits into one clean commit (keeping DCO sign-off) so commit history reflects the final API directly.
Once updated (and rebased if any of #10–#12 merge ahead of it and touch API.md/README.md), this is ready for CI and merge.
Add GetReservationsForResources, which follows Neutron's get_reservations_for_resources(expired=False) for every project at once. It returns one row per active reservation delta (reservation ID, project ID, expiration, resource and amount), ordered by project, resource and reservation ID. Amounts are returned as stored, including NULL and negative values, rather than summed. A reservation is active when expiration >= UTC_TIMESTAMP(), the same inclusive boundary Neutron uses. The comparison runs on the database clock in UTC, so caller clock skew and session time zones do not affect the result. The resources to read are a positional argument; an empty list matches nothing, as upstream. NULL owners are excluded and empty-string owners are kept, matching GetQuotas and GetResourceCountsByProject, so limits, usage and reservations join on project ID without special cases. GetResourceCountsByProject is unchanged. GetQuotas now orders by project, resource and quota ID so callers that collapse duplicate rows get a stable result. Add the reservations and resourcedeltas tables to the Neutron schema fixture, without indexes on expiration or project_id as upstream. Add unit tests, MariaDB integration tests for reservations and quota owner handling and ordering, and API.md documentation. Co-authored-by: David Hulick <dave.hulick@gmail.com> Signed-off-by: David Hulick <dave.hulick@gmail.com> Signed-off-by: Jeremy Lee <jeremy.lee1664@gmail.com>
Jeremy Lee (legit-ninja)
force-pushed
the
contrib/neutron-2b4
branch
from
December 3, 2026 18:23
d3a59e4 to
75cf35c
Compare
Mohammed Naser (mnaser)
approved these changes
Dec 4, 2026
Mohammed Naser (mnaser)
left a comment
Member
There was a problem hiding this comment.
Thanks for the updates—CI is green, approving and merging.
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.
Summary
Add
GetReservationsForResourcestoneutron/db, and orderGetQuotasresults.GetReservationsForResourcesfollows Neutron's[get_reservations_for_resources(..., expired=False)](https://github.com/openstack/neutron/blob/master/neutron/db/quota/api.py)for every project at once. It returns one row per active reservation delta (ReservationID,ProjectID,Expiration,Resource,Amount) instead of a per-resource sum.Motivation
Neutron's quota usage plus its active reservations is what Neutron checks new requests against.
GetQuotasandGetResourceCountsByProjectalready expose limits and usage; this adds the reservations so consumers can see the full picture.Behavior
expiration >= UTC_TIMESTAMP(), the same inclusive boundary Neutron uses. The comparison runs on the database clock in UTC, because Neutron writes expirations in UTC, so caller clock skew and the session time zone do not affect the result. NULL expirations are never active.resourcesis a positional argument and follows upstream: a nil or empty list matches nothing rather than every resource.GetQuotasandGetResourceCountsByProject, so limits, usage and reservations join onProjectIDwithout special cases.GetQuotasnow orders by project, resource and quota ID, so callers that collapse duplicate rows get a stable result.Performance
Upstream Neutron defines no index on
reservations.expirationorreservations.project_id, and the schema fixture mirrors that. Each call scansreservationsand joinsresourcedeltasthrough the index InnoDB creates for itsreservation_idforeign key, the same access path Neutron's own quota engine uses. The table stays small while Neutron's expired-reservation cleanup runs.Compatibility
The change is additive.
GetResourceCountsByProjectis unchanged.GetQuotasreturns the same rows, now in a defined order. Thereservationsandresourcedeltastables are added to the Neutron schema fixture for tests and code generation; they are not production migrations.Tests and docs
TestNeutronReservationsForResources,TestNeutronQuotaOwnersAndOrdering) using expirations relative to the database clock.API.md;README.mdonly updates theneutron/dbsummary row.