STO-67: fast-fail Model Repo storage quota check - #338
Open
jebenexer wants to merge 1 commit into
Open
Conversation
1 task
Adds a client-side check that fails fast, before creating the model or a single upload session, when a local upload would exceed the account's Model Repo storage quota. - api.GetModelRepoStorageUsage: wraps the server's modelRepoStorageUsage query (runpod/RunPod#5929). - checkModelRepoStorageQuota: compares the total local upload size against availableBytes and returns a clear, actionable error when it would be exceeded. Fails OPEN on any query error or unparseable response (older server, transient network issue) -- a client-side pre-check must never itself become the reason an otherwise-valid upload fails. Skipped entirely when enforcement is disabled server-side. - Wired into runAddModel right after the existing file-name/file-size validation, before addModelToRepo is called for either the --model-path (directory) or single-file (--file-name/--file-size) upload flows. - Storage-usage query failures go through modelRepoHTTPError/ modelRepoGraphQLError like the rest of the model-repo API surface, so access-denied and other server errors carry a stable error code (the STO-357 contract) rather than a bare string. Testing: go build/vet/test clean across the whole module. - cmd/model/modelRepoQuota_test.go covers the quota check's allow/deny/boundary/fail-open behavior and modelUploadRequestedBytes' directory-vs-flag size resolution. - api/model_test.go covers GetModelRepoStorageUsage response parsing, owner-variable omission, and graphql error surfacing, and the model-repo access-denied table test gains an entry for it. - One end-to-end test confirms addModelToRepo/createModelRepoUpload are never called when the fast-fail check rejects the upload.
jebenexer
force-pushed
the
benjaminbrannaka/sto-67-model-repo-storage-limit
branch
from
September 10, 2026 03:06
45f8fcf to
36a185e
Compare
Collaborator
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 36a185e. Configure here.
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.
Resolves STO-67.
Server-side counterpart: runpod/RunPod#5929.
#339 (STO-366, pre-signed URL batching) is independent — this check runs before
session creation either way.
Problem
runpodctlalready knows the total model size before uploading, but goesstraight into session creation with no check against the account's storage
quota. An over-quota upload should fail immediately with a useful message,
not after creating a model and partial upload sessions server-side.
Changes
api.GetModelRepoStorageUsagewraps the newmodelRepoStorageUsagequery.checkModelRepoStorageQuotacompares the total upload size againstavailableBytesand returns an actionable error when it would be exceeded.It fails open: a query error or unparseable response warns and proceeds,
since a client-side pre-check must never itself break a valid upload. Skipped
when enforcement is off (
Enforced: false) or no quota is set(
AvailableBytes: nil).createModelRepoUpload's server-side gate is stillthe real limit.
runAddModelafter file-name/file-size validation and beforeaddModelToRepo, covering both--model-pathand single-file flows.Testing
go vet ./...,go build ./...,go test ./...,govulncheck ./...checkModelRepoStorageQuotaallow/deny/boundary/fail-open, andmodelUploadRequestedBytes' directory-vs-flag size resolution.GetModelRepoStorageUsage, including its entry in theSTO-357 typed-error table.
addModelToRepoandcreateModelRepoUploadarenever reached when the check rejects the upload.
Note
Low Risk
Adds an optional pre-upload check that fails open on API errors; no change to server enforcement or non-upload flows (e.g. Hugging Face mirror).
Overview
Adds a client-side Model Repo storage quota pre-check so
runpodctl model addcan reject over-quota uploads beforeaddModelToRepoor upload sessions are created.The API layer gains
ModelRepoStorageUsageandGetModelRepoStorageUsage, calling themodelRepoStorageUsageGraphQL query (optionalowner, byte fields as strings). Inmodel add,checkModelRepoStorageQuotacompares the planned upload size—from--model-pathtotals or--file-size—againstavailableByteswhenenforcedis true, returning a clear error if the upload would exceed quota. The check fails open on query/parse errors (stderr warning only) so the CLI never blocks uploads when usage cannot be read; server-side enforcement oncreateModelRepoUploadremains authoritative. Quota validation runs after upload flag validation and before any model creation.Tests cover API parsing/GraphQL errors, quota allow/deny/boundary/fail-open behavior, byte-size resolution, and an integration case that
addModelToRepo/createModelRepoUploadare not invoked when over quota.Reviewed by Cursor Bugbot for commit 36a185e. Configure here.