8000 feat(rod): build user allocations from per-author storage rows by janzak-dev · Pull Request #1596 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content
< 8000 link crossorigin="anonymous" rel="modulepreload" href="https://github.githubassets.com/assets/app-install-banner-partial-20f8b29fb105a109.js" fetchpriority="low" />

feat(rod): build user allocations from per-author storage rows - #1596

Closed
janzak-dev wants to merge 2 commits into
feat/rod-user-alloc-api-scaffoldfrom
feat/rod-user-alloc-backend-mapping
Closed

janzak-dev wants to merge 2 commits into
feat/rod-user-alloc-api-scaffoldfrom
feat/rod-user-alloc-backend-mapping

Conversation

@janzak-dev
@janzak-dev janzak-dev commented Nov 6, 2026 •
Copy link
Copy Markdown
Collaborator

Note

Stacked PR (part of #1515): per-user "dominant resource" allocation on /resources. Each layer has a production caller and tests (no dead code); unfinished backend pieces return empty data, never placeholder values.

Endpoint scaffold

  1. feat(rod): add per-user allocations to GetRunningAndPendingJobs #1595 Proto user_allocations + UI response type; the field stays empty

Backend: RPC presents correct information
2. #1596 Storage contract + per-author mapping (backends return no rows yet, so the field stays empty)
3. #1597 Spanner + Postgres aggregation (field is populated)
4. #1598 Jobs page and aggregation from one read-only snapshot

Frontend: UI presents correct data
5. #1599 Per-user allocation bar on /resources

Summary

Adds the storage contract WorkUnitStore.AggregateActiveResourcesByAuthor, returning per-author rows (storage.AuthorResourceAllocation: author, resource type, running or pending state, units). GetRunningAndPendingJobs now builds user_allocations from those rows. The Spanner and Postgres implementations return no rows until the next PR implements the aggregation, so the field stays empty.

Motivation & Context

The first backend layer: it lands the storage contract and the real mapping to the API, so the next layer only has to implement the queries.

Key Changes

  • internal/storage/storage.go: ActiveResourceState (RUNNING / PENDING), AuthorResourceAllocation, and WorkUnitStore.AggregateActiveResourcesByAuthor. MockStorage is updated.
  • Spanner and Postgres AggregateActiveResourcesByAuthor: return an empty slice (documented as not yet implemented).
  • cmd/rod_data_provider/user_allocations.go: groups rows per user and resource type, sums running and pending, and sorts by total units with deterministic tie-breakers. When the queue has exactly one GPU flavor, a generic nvidia.com/gpu request is attributed to that flavor's model (via the existing resolveResourceType).
  • jobs.go: fetchJobsAndAllocations fetches the jobs page, then the per-author rows, and maps them. An aggregation error fails the RPC with codes.Internal. WorkUnitFetcher is updated.

Assumptions

  • A generic GPU request is attributed to a model only when the queue has a single GPU flavor. With several flavors it stays nvidia.com/gpu, so a specific-model filter can miss it, but the parent filter always includes it.

Verification & Testing

  • bazel test //cmd/rod_data_provider/... //internal/storage/...: all pass. That includes mapping, ordering and tie-breaker tests, single-flavor vs multi-flavor GPU attribution, handler tests (allocations mapped from storage rows, aggregation error → Internal), and empty-result tests for both backends.
  • ./.githooks/pre-commit: passes.

Related Issues / Bugs

Part of #1515

TAG=agy
CONV=4ed50232-a6f2-4c76-aa6f-ef1c3833a550

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the rod_data_provider service to dynamically map and group author resource allocations instead of using static mock user allocations. It introduces new data structures in the storage package and implements logic to resolve generic accelerators to specific queue flavors. The review feedback points out a potential nil pointer dereference panic in buildUniqueQueueAcceleratorMap when retrieving a cluster queue from the cache, suggesting an additional nil check.

@janzak-dev janzak-dev left a comment
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. I checked each suggestion against the code in this stack; replies with the reasoning are inline. No code changes were needed in this round.

Add UserResourceAllocation (user, resource type, running and pending
units) and GetRunningAndPendingJobsResponse field 4 (user_allocations),
plus the matching UI response type. The field stays empty until the
backend aggregates allocations from active work units.

Bug: 582253355
TAG=agy
CONV=4ed50232-a6f2-4c76-aa6f-ef1c3833a550
Add storage.AuthorResourceAllocation (author, resource type, running or
pending state, units) and WorkUnitStore.AggregateActiveResourcesByAuthor.
GetRunningAndPendingJobs calls it after fetching the jobs page and maps
the rows to user_allocations: group per user and resource type,
attribute a generic nvidia.com/gpu request to the queue's GPU model when
the queue has exactly one GPU flavor, and sort by total units.

The Spanner and Postgres implementations return no rows until the
aggregation over active work units is implemented, so user_allocations
stays empty.

Bug: 582253355
TAG=agy
CONV=4ed50232-a6f2-4c76-aa6f-ef1c3833a550
@janzak-dev
janzak-dev force-pushed the feat/rod-user-alloc-backend-mapping branch from 3898e44 to 98ee93c Compare November 6, 2026 13:10
@janzak-dev
janzak-dev force-pushed the feat/rod-user-alloc-api-scaffold branch from 1d1d649 to 1c8a5aa Compare November 6, 2026 13:10
@janzak-dev janzak-dev changed the title feat(rod): map per-author resource rows to user allocations feat(rod): build user allocations from per-author storage rows Nov 6, 2026
@janzak-dev
janzak-dev removed this pull request from stack #1600 8000 November 6, 2026 13:49
@janzak-dev
janzak-dev force-pushed the feat/rod-user-alloc-api-scaffold branch from 1c8a5aa to a458068 Compare November 6, 2026 13:55
@janzak-dev
Copy link
Copy Markdown
Collaborator Author

Folded into #1595 so the user_allocations field lands together with its producer (the handler mapping). Stack: #1595 → #1597 → #1598 → #1599.

@janzak-dev janzak-dev closed this Nov 6, 2026
@janzak-dev
janzak-dev deleted the feat/rod-user-alloc-backend-mapping branch November 6, 2026 15:29
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

0