From 2e71083901f225cebbe365e32ff7220b5d8d34e0 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Mon, 30 Nov 2026 17:20:33 +0100 Subject: [PATCH 1/9] chore(serverless): sync the API spec with the published bundle Copies the published Serverless API bundle with make sync-serverless-spec and regenerates the client. No hand edits. The bundle adds the usage object (storedBytes) to the Shared Volume settings, GET /v1/regions with the regions field on apps, and description updates for private base images and registry secrets, the idle timeout floor, a task's endpoint id and the commitment region. --- api/serverless/openapi.yaml | 121 ++++++++-- internal/api/serverless/gen/client.gen.go | 262 ++++++++++++++++++++-- 2 files changed, 348 insertions(+), 35 deletions(-) diff --git a/api/serverless/openapi.yaml b/api/serverless/openapi.yaml index 6328d57..6f149b8 100644 --- a/api/serverless/openapi.yaml +++ b/api/serverless/openapi.yaml @@ -56,9 +56,9 @@ paths: get: tags: - Volumes - summary: Read Shared Volume access and limits + summary: Read Shared Volume access, limits and usage description: | - Returns effective access and limits for the authenticated organization. The two are read separately, so a change made while the request runs can show access and limits that never held together. This setting does not indicate whether Shared Volume operations are deployed. + Returns effective access, limits and stored-byte usage for the authenticated organization. The three are read separately, so a change made while the request runs can show values that never held together. This setting does not indicate whether Shared Volume operations are deployed. operationId: getVolumeSettings responses: '200': @@ -894,6 +894,27 @@ paths: $ref: '#/components/responses/VolumeNotImplemented' '503': $ref: '#/components/responses/ServiceUnavailable' + /v1/regions: + get: + tags: + - Compute + summary: List regions + description: | + Returns the regions the caller's organization may name. The request requires authentication. By default that is `global`, where the platform picks where to run, and every open region. An organization can be limited to fewer regions, or let into a region that is not open yet; then exactly those are listed. The list is small, so the response is the whole list, `global` first, then by `code`. + operationId: listRegions + responses: + '200': + description: Regions the organization may name + content: + application/json: + schema: + $ref: '#/components/schemas/RegionList' + '401': + $ref: '#/components/responses/Unauthorized' + '500': + $ref: '#/components/responses/InternalServerError' + '503': + $ref: '#/components/responses/ServiceUnavailable' /v1/gpu-types: get: tags: @@ -5199,7 +5220,7 @@ components: configPointer: /endpoints/0 AppSourceValidationError: description: | - The request was well-formed but invalid. A field of the request body that broke the schema or a rule is `unprocessable-entity`. A container source whose archive or `container.yaml` broke a contract rule carries the rule's own type and `errors[]`. A source whose base image the registry would not serve, or which names the platform's own image registry, is `base-image-unreadable`. The detail names the registry host and the image reference. For a code source, one `errors[]` entry points at `baseImage`. An entry about a field of `container.yaml` has a `configPointer` to that field and a `pointer` to the archive in the request body. An entry about the archive has neither. A code source's archive rejection is `unprocessable-entity`. A secret attachment that names a secret the environment does not hold as active is `secret-not-found`, with one `errors[]` entry per attachment pointing at `secretName`. A request that could not be parsed returns `400`. + The request was well-formed but invalid. A field of the request body that broke the schema or a rule is `unprocessable-entity`. An app that the organization's settings do not allow is `unprocessable-entity` too; the detail says why. So is a create's `regions` that names a region the organization may not use, more than one region, or a region with no pool of the GPU type; `errors[]` points at the entry or at `gpuType`. So is an update's `regions` that is not the one change allowed, pinning a global app to the region it runs in; `errors[]` points at the entry and the detail says why. A container source whose archive or `container.yaml` broke a contract rule carries the rule's own type and `errors[]`. A source whose base image the registry would not serve, or which names the platform's own image registry, is `base-image-unreadable`. A private base the credential covers is accepted here, and a refused pull the build classifies after it starts is that build's `failureSlug`. The detail names the registry host and the image reference. For a code source, one `errors[]` entry points at `baseImage`. An entry about a field of `container.yaml` has a `configPointer` to that field and a `pointer` to the archive in the request body. An entry about the archive has neither. A code source's archive rejection is `unprocessable-entity`. A secret attachment that names a secret the environment does not hold as active is `secret-not-found`, with one `errors[]` entry per attachment pointing at `secretName`. A request that could not be parsed returns `400`. content: application/problem+json: schema: @@ -5275,12 +5296,12 @@ components: errors: - detail: the archive must contain "Dockerfile" at its root (exact name, case sensitive) base-image-unreadable: - summary: The registry would not serve the base image + summary: The registry would not serve the base image, and no credential was presented value: type: https://docs.runware.ai/serverless/errors#base-image-unreadable title: Unprocessable Entity status: 422 - detail: 'base-image-unreadable: ghcr.io: ghcr.io/acme/private:1 could not be pulled. Private base images are not supported in this version' + detail: 'base-image-unreadable: ghcr.io: ghcr.io/acme/private:1 could not be pulled. A private base must be pinned to a digest. Where this environment enables registry credentials, the source names one' container-config-unknown-version: summary: container.yaml names an unknown configVersion value: @@ -5489,12 +5510,27 @@ components: required: - available - limits + - usage properties: available: type: boolean description: Effective access including the saved beta switch, tenancy and organization lifecycle. limits: $ref: '#/components/schemas/VolumeLimits' + usage: + $ref: '#/components/schemas/VolumeUsage' + VolumeUsage: + type: object + additionalProperties: false + required: + - storedBytes + properties: + storedBytes: + type: integer + format: int64 + minimum: 0 + description: | + Stored bytes: the plaintext sizes of the distinct files the latest files of the organization's Volumes reference. A file counts once however many Volumes, apps or environments use it, and stops counting when no Volume references it. This is the usage `maxStoredBytes` limits. An upload is admitted against it plus the content unfinished upload sessions hold and the content upload sessions, finished or not, left in storage until cleanup removes it, so an upload can be refused before `storedBytes` reaches `maxStoredBytes`. VolumeLimits: type: object additionalProperties: false @@ -6723,7 +6759,7 @@ components: SecretType: type: string description: | - Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). + Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. Saving one for ECR uses username `AWS` and the password from `aws ecr get-login-password`, which lasts about twelve hours; the host is `ACCOUNT.dkr.ecr.REGION.amazonaws.com`. Nothing refreshes that password. Replace the secret before it expires, or each build that names it fails as `base-image-unauthorized`, including a public digest-pinned image on the same host. `docker.io`, `registry-1.docker.io` and `https://index.docker.io/v1/` are stored as `index.docker.io`. The build presents that login to BuildKit as `https://index.docker.io/v1/`. Every other registry is presented as its normalized host. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). enum: - generic - registry @@ -6750,6 +6786,47 @@ components: A `GpuTypeId`, or the empty string. Optional fallback GPU fields accept `""` because forms bind an unselected dropdown as empty rather than omitting the key. A non-empty value has the same shape as `GpuTypeId`. Keep this pattern aligned when the catalog-code format changes. maxLength: 64 pattern: ^$|^[a-z][a-z0-9_-]{0,63}$ + RegionCode: + type: string + description: | + Code of a region in the region catalog (e.g. `eu`, `na`, `global`). + minLength: 1 + maxLength: 32 + pattern: ^[a-z][a-z0-9-]{0,31}$ + Region: + type: object + additionalProperties: false + required: + - code + - name + properties: + code: + $ref: '#/components/schemas/RegionCode' + name: + type: string + description: Human-readable region name (e.g. `Europe`). + minLength: 1 + maxLength: 64 + pattern: ^\S(.*\S)?$ + RegionList: + type: object + additionalProperties: false + required: + - data + properties: + data: + type: array + items: + $ref: '#/components/schemas/Region' + AppRegions: + type: array + description: | + Where the app runs, as codes from `GET /v1/regions`. `["global"]` lets the platform pick; one region keeps the app's workers in that region. Only one entry is accepted for now: more than one returns `422`. Set when the app is created; an update can only pin a global app to the region it runs in. + minItems: 1 + maxItems: 8 + uniqueItems: true + items: + $ref: '#/components/schemas/RegionCode' GpuAvailability: type: string description: | @@ -7362,11 +7439,17 @@ components: - environmentVariables - status - isFavorite + - regions - createdAt - updatedAt properties: appId: $ref: '#/components/schemas/AppId' + regions: + allOf: + - $ref: '#/components/schemas/AppRegions' + description: | + Where the app runs: `["global"]` when the create named no region, else the region it named or the app was pinned to. environment: allOf: - $ref: '#/components/schemas/EnvironmentName' @@ -7468,6 +7551,11 @@ components: $ref: '#/components/schemas/AppName' configuration: $ref: '#/components/schemas/WorkerConfigCreate' + regions: + allOf: + - $ref: '#/components/schemas/AppRegions' + description: | + Where the app runs. Omitted is `["global"]`. A named region places every worker there, on a pool of `configuration.gpuType` in that region. A code the organization may not use returns `422` pointing at `/regions/0`, and a GPU type with no pool in the region returns `422` that names both. appSource: allOf: - $ref: '#/components/schemas/AppSourceUpsert' @@ -7542,6 +7630,11 @@ components: maxItems: 100 items: $ref: '#/components/schemas/SecretAttach' + regions: + allOf: + - $ref: '#/components/schemas/AppRegions' + description: | + Pins a `global` app to the region it runs in, named as its one entry. A `global` app's `regions` does not show that region; a `422` for another region names it. The pin moves nothing: on its own it records no version and restarts no worker. A pin cannot be undone. Sending the app's current `regions` changes nothing. More than one entry returns `422` pointing at `/regions/1`. Any other change returns `422` pointing at `/regions/0`: back to `global`, another region than the one the app runs in (create a new app to move it), a region the organization may not use, an app that runs in no region, or a region the app cannot be pinned to yet. A pin together with `appSource` returns `422`; send it in its own update. environmentVariables: type: object description: | @@ -7627,7 +7720,7 @@ components: type: integer format: int32 description: | - Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. + Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. scalingDelaySecs: type: integer format: int32 @@ -7726,7 +7819,7 @@ components: format: int32 minimum: 1 description: | - Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. + Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. scalingDelaySecs: type: integer format: int32 @@ -7806,7 +7899,7 @@ components: format: int32 minimum: 1 description: | - Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. Omit to leave unchanged. + Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. Omit to leave unchanged. scalingDelaySecs: type: integer format: int32 @@ -8368,12 +8461,12 @@ components: - $ref: '#/components/schemas/SourceId' pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ description: | - Id of a source published by a completed upload in this organization (`POST /v1/source-uploads`, then `complete`). The archive it names carries a wrapper `Dockerfile` and a `container.yaml` config document at its root, plus any build-context files the Dockerfile copies in. Runware builds the image from it, resolving the Dockerfile's base images to immutable digests, and hosts the result. The customer supplies no image to run. A private base image names `sourceImageCredential`, a registry secret in this environment. An invalid `container.yaml` rejects the create: `400` where the document could not be parsed, `422` where it parsed and broke a rule, with `errors[]` entries carrying `configPointer` into the document. The endpoint set it declares becomes visible once the first build is ready and deployed. A source is immutable and reusable: the same `sourceId` may back any number of apps and versions in the organization. + Id of a source published by a completed upload in this organization (`POST /v1/source-uploads`, then `complete`). The archive it names carries a wrapper `Dockerfile` and a `container.yaml` config document at its root, plus any build-context files the Dockerfile copies in. Runware builds the image from it, resolving base images it can read to immutable digests, and hosts the result. The customer supplies no image to run. A private base is a `FROM` pinned to a digest (`image@sha256:…`). An explicit `:443` is the same host as no port, and `sourceImageCredential` names the registry secret that pulls it. A private base whose labels cannot be read is not classified as vLLM or SGLang and is not served under Dynamo. A `COPY --from` resolves when it names a stage (`FROM image@sha256:… AS src`, then `COPY --from=src`). An invalid `container.yaml` rejects the create: `400` where the document could not be parsed, `422` where it parsed and broke a rule, with `errors[]` entries carrying `configPointer` into the document. The endpoint set it declares becomes visible once the first build is ready and deployed. A source is immutable and reusable: the same `sourceId` may back any number of apps and versions in the organization. sourceImageCredential: allOf: - $ref: '#/components/schemas/SourceImageCredentialName' description: | - A `registry` secret in this environment. The build uses it to pull the Dockerfile's private base images. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A deleted secret is `422` `secret-not-found`, and no build starts. + Name of a `registry` secret in this environment. The build presents it only to the hosts the secret lists, and only for a digest-pinned base. An explicit `:443` is the same host as no port; any other port is not. A registry that refuses it fails the build with `failureSlug` `base-image-unauthorized`. A base it does not cover fails as `base-image-unreadable`. A registry that does not answer fails as `base-image-registry-unavailable`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A request that names a deleted secret is `422` `secret-not-found` before any build Job. CodebaseSource: type: object additionalProperties: false @@ -8432,7 +8525,7 @@ components: allOf: - $ref: '#/components/schemas/SourceImageCredentialName' description: | - A `registry` secret in this environment. The build uses it to pull a private `baseImage`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A deleted secret is `422` `secret-not-found`, and no build starts. + Name of a `registry` secret in this environment. The build presents it only to the hosts the secret lists, and only for a digest-pinned `baseImage`. An explicit `:443` is the same host as no port; any other port is not. A registry that refuses it fails the build with `failureSlug` `base-image-unauthorized`. A base it does not cover fails as `base-image-unreadable`. A registry that does not answer fails as `base-image-registry-unavailable`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A request that names a deleted secret is `422` `secret-not-found` before any build Job. DeployRequest: type: object required: @@ -9086,7 +9179,7 @@ components: type: string format: uuid description: | - Allocated endpoint row, the same UUID as `Endpoint.id`. Present when the live row at `endpointPath` was created at or before this task. Omitted when that path has no live row, when this task has no creation time, and when this task predates the live row: a path removed and added again is a different endpoint, and this id must not name it. Metrics filters take this id, not `endpointPath`. + Allocated endpoint row, the same UUID as `Endpoint.id`. Present when the live row at `endpointPath` was created at or before this task. Omitted when that path has no live row, when this task has no creation time, and when this task predates the live row: a path removed and added again is a different endpoint, and this id must not name it. Read from a cache, so it is best effort: also omitted when the cached endpoint rows are older than this task and could not be read again (a later read returns it), and a removed endpoint's id can still be returned for a short while after the removal. Metrics filters take this id, not `endpointPath`. output: description: | Inference result payload on success. Null otherwise. May be any JSON value, including an object, array, string, number, boolean, or null. For a code app this is the value the handler returned, or the value `encode_response` returned when the app defines one: it is not wrapped, and a single request's value is that return rather than a one-element list of it. For a container app this is the response body the container returned. Absent on a listed task whose `outputOmitted` is `true`. @@ -9127,7 +9220,7 @@ components: UsageRegion: type: string description: | - The region a capacity commitment applies to. One value until app placement selects a region. + The billing region a capacity commitment applies to, not a region of the region catalog. enum: - default UsageBucket: diff --git a/internal/api/serverless/gen/client.gen.go b/internal/api/serverless/gen/client.gen.go index 3c9e4fe..a7ec39b 100644 --- a/internal/api/serverless/gen/client.gen.go +++ b/internal/api/serverless/gen/client.gen.go @@ -1411,6 +1411,9 @@ type App struct { // Mounts The Shared Volumes of the version an update copies, in byte order of `mountPath`, as that version's `mounts` lists them: the version `activeVersionId` names, or the latest version while it is null, such as after a create whose first rollout failed. Populated on the app reads only: `GET /v1/apps/{appId}` and `GET /v1/apps`. Every other response that carries an app omits it; read the app again after a mutation. Within those two reads it is omitted when that version mounts no Shared Volume, the app is deleted, or Shared Volumes are not available to the organization. Beta: Shared Volumes must be enabled for the organization, and this field may change before general availability. Mounts *[]VolumeMount `json:"mounts,omitempty"` + // Regions Where the app runs: `["global"]` when the create named no region, else the region it named or the app was pinned to. + Regions AppRegions `json:"regions"` + // Runtime Observed state for one app at `calculatedAt`. Desired worker scale remains in `configuration`. Worker and GPU counts are always present. Traffic, duration, and queue fields are omitted when their backing data is unavailable. Runtime AppRuntime `json:"runtime"` @@ -1454,6 +1457,9 @@ type AppCreate struct { // Example: [{"kind":"volume","mountPath":"/mnt/models","name":"model-weights"}] Mounts *[]VolumeMount `json:"mounts,omitempty"` + // Regions Where the app runs. Omitted is `["global"]`. A named region places every worker there, on a pool of `configuration.gpuType` in that region. A code the organization may not use returns `422` pointing at `/regions/0`, and a GPU type with no pool in the region returns `422` that names both. + Regions *AppRegions `json:"regions,omitempty"` + // Secrets Existing secrets of this app's environment to attach to it, with an optional env-var name override per entry. This is the app's initial attachment set, so the first rollout carries the values into the worker. The secret must already exist and be `active`. This route does not create one. An unknown or inactive name returns `422` typed `secret-not-found`, and `errors[]` points at that entry's `secretName`. A `registry` secret returns `422` `secret-not-attachable`. Shape matches `POST /apps/{appId}/secrets` so create and attach share one contract. Each injected name must not collide with a key in `environmentVariables`. See `SecretAttach`. Each secret can also be attached to at most 25 deployments total, shared with every other route that attaches it. An entry that would push a secret past that returns `422`. Secrets *[]SecretAttach `json:"secrets,omitempty"` @@ -1607,6 +1613,9 @@ type AppOidcConnector struct { UpdatedAt time.Time `json:"updatedAt"` } +// AppRegions Where the app runs, as codes from `GET /v1/regions`. `["global"]` lets the platform pick; one region keeps the app's workers in that region. Only one entry is accepted for now: more than one returns `422`. Set when the app is created; an update can only pin a global app to the region it runs in. +type AppRegions = []RegionCode + // AppRuntime Observed state for one app at `calculatedAt`. Desired worker scale remains in `configuration`. Worker and GPU counts are always present. Traffic, duration, and queue fields are omitted when their backing data is unavailable. type AppRuntime struct { // ActiveWorkers Non-terminal workers (`status` other than `stopped`) on this app's active version. Pending workers count because they appear in the active-version workers list before Kubernetes assigns a GPU. So do workers that cannot take a task yet or any more, such as `loading` or `unhealthy`: `servingWorkers` is the count of those that can. Outgoing-version workers are excluded because the default workers list omits them. A deleted app reports zero. @@ -1713,6 +1722,9 @@ type AppUpdate struct { // Mounts Replaces the app's Shared Volume mounts in the version this update records, which then rolls out as a configuration change does. An empty array removes them; omitted keeps the mounts of the version the update copies. Beta: Shared Volumes must be enabled for the organization, and this field may change before general availability. Without Shared Volume beta access, a non-empty array is refused with `422` pointing at `/mounts`, detail `Shared Volumes are not available to this organization`. An empty array is accepted without access, so an app whose organization lost access can remove its mounts. Refusals are those of `AppCreate.mounts`, judged against the node-local `volumes` the new version keeps, except that the `409` for `maxMountedBytesPerAppVersion` answers only an update that makes its version current, or a source update when it records the version before its build; an update copied onto a build that is not ready is checked by the deploy that makes it current. An update that keeps mounts of a Volume deleted since is refused with `422` pointing at `/mounts`; send `mounts` to replace them. An update without `mounts` that moves `gpuType` or `gpusPerWorker` to one whose workers cannot mount Shared Volumes, while the app keeps mounts, is refused with `422` pointing at that field. An update that makes a version with mounts current while Shared Volumes are not available to the organization is refused with `409`. Mounts *[]VolumeMount `json:"mounts,omitempty"` + // Regions Pins a `global` app to the region it runs in, named as its one entry. A `global` app's `regions` does not show that region; a `422` for another region names it. The pin moves nothing: on its own it records no version and restarts no worker. A pin cannot be undone. Sending the app's current `regions` changes nothing. More than one entry returns `422` pointing at `/regions/1`. Any other change returns `422` pointing at `/regions/0`: back to `global`, another region than the one the app runs in (create a new app to move it), a region the organization may not use, an app that runs in no region, or a region the app cannot be pinned to yet. A pin together with `appSource` returns `422`; send it in its own update. + Regions *AppRegions `json:"regions,omitempty"` + // Secrets Replaces the app's secret attachments. Same `SecretAttach` shape as create and `POST /apps/{appId}/secrets`. An unknown or inactive name returns `422` typed `secret-not-found`, and `errors[]` points at that entry's `secretName`. A `registry` secret returns `422` `secret-not-attachable`. An attachment absent from the array is detached. Injected names must not collide with a plain environment variable on the app. The attachment set is stored on the app, not on the version snapshot. A rollout reads it fresh and the worker unseals each value into its process environment under the resolved env-var name. A secrets-only change records a version and does not pin it. This field does not roll the workload. The new set reaches a running worker on the next rollout. `POST /v1/apps/{appId}/secrets`, `DELETE /v1/apps/{appId}/secrets/{secretName}`, and `PUT /v1/secrets/{secretName}` roll a live deployment themselves. An app holds at most 100 environment bindings in total. This array cannot exceed that ceiling on its own. Each individual secret can also be attached to at most 25 deployments total, shared with every other route that attaches it. Secrets *[]SecretAttach `json:"secrets,omitempty"` } @@ -1943,7 +1955,7 @@ type CodeSourceUpsert struct { // Requirements Additional pip packages to install alongside the codebase. Requirements *[]string `json:"requirements,omitempty"` - // SourceImageCredential A `registry` secret in this environment. The build uses it to pull a private `baseImage`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A deleted secret is `422` `secret-not-found`, and no build starts. + // SourceImageCredential Name of a `registry` secret in this environment. The build presents it only to the hosts the secret lists, and only for a digest-pinned `baseImage`. An explicit `:443` is the same host as no port; any other port is not. A registry that refuses it fails the build with `failureSlug` `base-image-unauthorized`. A base it does not cover fails as `base-image-unreadable`. A registry that does not answer fails as `base-image-registry-unavailable`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A request that names a deleted secret is `422` `secret-not-found` before any build Job. SourceImageCredential *SourceImageCredentialName `json:"sourceImageCredential,omitempty"` } @@ -1977,10 +1989,10 @@ type ComputeType string // ContainerSource defines model for ContainerSource. type ContainerSource struct { - // SourceId Id of a source published by a completed upload in this organization (`POST /v1/source-uploads`, then `complete`). The archive it names carries a wrapper `Dockerfile` and a `container.yaml` config document at its root, plus any build-context files the Dockerfile copies in. Runware builds the image from it, resolving the Dockerfile's base images to immutable digests, and hosts the result. The customer supplies no image to run. A private base image names `sourceImageCredential`, a registry secret in this environment. An invalid `container.yaml` rejects the create: `400` where the document could not be parsed, `422` where it parsed and broke a rule, with `errors[]` entries carrying `configPointer` into the document. The endpoint set it declares becomes visible once the first build is ready and deployed. A source is immutable and reusable: the same `sourceId` may back any number of apps and versions in the organization. + // SourceId Id of a source published by a completed upload in this organization (`POST /v1/source-uploads`, then `complete`). The archive it names carries a wrapper `Dockerfile` and a `container.yaml` config document at its root, plus any build-context files the Dockerfile copies in. Runware builds the image from it, resolving base images it can read to immutable digests, and hosts the result. The customer supplies no image to run. A private base is a `FROM` pinned to a digest (`image@sha256:…`). An explicit `:443` is the same host as no port, and `sourceImageCredential` names the registry secret that pulls it. A private base whose labels cannot be read is not classified as vLLM or SGLang and is not served under Dynamo. A `COPY --from` resolves when it names a stage (`FROM image@sha256:… AS src`, then `COPY --from=src`). An invalid `container.yaml` rejects the create: `400` where the document could not be parsed, `422` where it parsed and broke a rule, with `errors[]` entries carrying `configPointer` into the document. The endpoint set it declares becomes visible once the first build is ready and deployed. A source is immutable and reusable: the same `sourceId` may back any number of apps and versions in the organization. SourceId SourceId `json:"sourceId"` - // SourceImageCredential A `registry` secret in this environment. The build uses it to pull the Dockerfile's private base images. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A deleted secret is `422` `secret-not-found`, and no build starts. + // SourceImageCredential Name of a `registry` secret in this environment. The build presents it only to the hosts the secret lists, and only for a digest-pinned base. An explicit `:443` is the same host as no port; any other port is not. A registry that refuses it fails the build with `failureSlug` `base-image-unauthorized`. A base it does not cover fails as `base-image-unreadable`. A registry that does not answer fails as `base-image-registry-unavailable`. Naming one when this environment has not enabled registry credentials is `422` `source-image-credential-not-enabled`. An unknown or inactive name is `422` `secret-not-found`. A secret of another type is `422` `secret-wrong-type`. Deleting or replacing the secret does not rebuild a version that names it. A request that names a deleted secret is `422` `secret-not-found` before any build Job. SourceImageCredential *SourceImageCredentialName `json:"sourceImageCredential,omitempty"` } @@ -2560,6 +2572,23 @@ type QueryCatalog struct { Metrics []CatalogEntry `json:"metrics"` } +// Region defines model for Region. +type Region struct { + // Code Code of a region in the region catalog (e.g. `eu`, `na`, `global`). + Code RegionCode `json:"code"` + + // Name Human-readable region name (e.g. `Europe`). + Name string `json:"name"` +} + +// RegionCode Code of a region in the region catalog (e.g. `eu`, `na`, `global`). +type RegionCode = string + +// RegionList defines model for RegionList. +type RegionList struct { + Data []Region `json:"data"` +} + // ReservedCapacity One commitment scope, a GPU type in a region, with what it reserves, what is using it and what overflowed past it. // // The counts belong to the scope rather than to a term, because two overlapping terms cover an allocation between them and neither can claim it alone. @@ -2598,7 +2627,7 @@ type ReservedCapacity struct { // PaygSpend Provisional overflow accrual, excluding finalization rounding and ledger adjustments. PaygSpend MoneyAmount `json:"paygSpend"` - // Region The region a capacity commitment applies to. One value until app placement selects a region. + // Region The billing region a capacity commitment applies to, not a region of the region catalog. Region UsageRegion `json:"region"` Terms []CommitmentTerm `json:"terms"` @@ -2624,7 +2653,7 @@ type Secret struct { // Names the platform sets in the worker's environment (for example `RUNTIME`, `DISABLE_NGINX`, `MLFLOW_MODELS_WORKERS`, `UVICORN_HOST`) are rejected with `422`: an accepted collision would replace a platform value the app depends on, be silently dropped in its favour, or reach the app under a name the platform uses for its own value, with no error anywhere. Same guard as plain environment variables. Enforced by the server (not expressible as a pattern here). Name SecretName `json:"name"` - // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). + // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. Saving one for ECR uses username `AWS` and the password from `aws ecr get-login-password`, which lasts about twelve hours; the host is `ACCOUNT.dkr.ecr.REGION.amazonaws.com`. Nothing refreshes that password. Replace the secret before it expires, or each build that names it fails as `base-image-unauthorized`, including a public digest-pinned image on the same host. `docker.io`, `registry-1.docker.io` and `https://index.docker.io/v1/` are stored as `index.docker.io`. The build presents that login to BuildKit as `https://index.docker.io/v1/`. Every other registry is presented as its normalized host. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). Type SecretType `json:"type"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` } @@ -2657,7 +2686,7 @@ type SecretAttachment struct { // Names the platform sets in the worker's environment (for example `RUNTIME`, `DISABLE_NGINX`, `MLFLOW_MODELS_WORKERS`, `UVICORN_HOST`) are rejected with `422`: an accepted collision would replace a platform value the app depends on, be silently dropped in its favour, or reach the app under a name the platform uses for its own value, with no error anywhere. Same guard as plain environment variables. Enforced by the server (not expressible as a pattern here). Name SecretName `json:"name"` - // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). + // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. Saving one for ECR uses username `AWS` and the password from `aws ecr get-login-password`, which lasts about twelve hours; the host is `ACCOUNT.dkr.ecr.REGION.amazonaws.com`. Nothing refreshes that password. Replace the secret before it expires, or each build that names it fails as `base-image-unauthorized`, including a public digest-pinned image on the same host. `docker.io`, `registry-1.docker.io` and `https://index.docker.io/v1/` are stored as `index.docker.io`. The build presents that login to BuildKit as `https://index.docker.io/v1/`. Every other registry is presented as its normalized host. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). Type SecretType `json:"type"` UpdatedAt *time.Time `json:"updatedAt,omitempty"` } @@ -2694,7 +2723,7 @@ type SecretCreate struct { // Names the platform sets in the worker's environment (for example `RUNTIME`, `DISABLE_NGINX`, `MLFLOW_MODELS_WORKERS`, `UVICORN_HOST`) are rejected with `422`: an accepted collision would replace a platform value the app depends on, be silently dropped in its favour, or reach the app under a name the platform uses for its own value, with no error anywhere. Same guard as plain environment variables. Enforced by the server (not expressible as a pattern here). Name SecretName `json:"name"` - // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). + // Type Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. Saving one for ECR uses username `AWS` and the password from `aws ecr get-login-password`, which lasts about twelve hours; the host is `ACCOUNT.dkr.ecr.REGION.amazonaws.com`. Nothing refreshes that password. Replace the secret before it expires, or each build that names it fails as `base-image-unauthorized`, including a public digest-pinned image on the same host. `docker.io`, `registry-1.docker.io` and `https://index.docker.io/v1/` are stored as `index.docker.io`. The build presents that login to BuildKit as `https://index.docker.io/v1/`. Every other registry is presented as its normalized host. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). Type SecretType `json:"type"` // Value Plain-text value. Encrypted at rest by the platform. Capped at 64 KiB, Cloud KMS Encrypt's plaintext ceiling, and the reason the design needs no envelope encryption (ADR-019). @@ -2706,7 +2735,7 @@ type SecretCreate struct { // Names the platform sets in the worker's environment (for example `RUNTIME`, `DISABLE_NGINX`, `MLFLOW_MODELS_WORKERS`, `UVICORN_HOST`) are rejected with `422`: an accepted collision would replace a platform value the app depends on, be silently dropped in its favour, or reach the app under a name the platform uses for its own value, with no error anywhere. Same guard as plain environment variables. Enforced by the server (not expressible as a pattern here). type SecretName = string -// SecretType Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). +// SecretType Kind of secret. `generic` is unsealed into the worker's process environment when the secret is attached to an app. `registry` is a Docker `config.json` whose only top-level key is `auths`. Each entry has `auth`, or `username` and `password`, or `identitytoken`. A value is `422` when it names `credHelpers` or `credsStore`, any other top-level key, an entry key other than `auth`, `username`, `password` or `identitytoken`, a key that is not a registry host (a host has a dot or a port, or is `localhost`), two keys that normalize to the same host, or a key that appears twice. The platform stores the ciphertext the same way as `generic` and keeps the normalized registry hosts beside it. Saving one for ECR uses username `AWS` and the password from `aws ecr get-login-password`, which lasts about twelve hours; the host is `ACCOUNT.dkr.ecr.REGION.amazonaws.com`. Nothing refreshes that password. Replace the secret before it expires, or each build that names it fails as `base-image-unauthorized`, including a public digest-pinned image on the same host. `docker.io`, `registry-1.docker.io` and `https://index.docker.io/v1/` are stored as `index.docker.io`. The build presents that login to BuildKit as `https://index.docker.io/v1/`. Every other registry is presented as its normalized host. A `registry` secret cannot be attached to an app (`422` `secret-not-attachable`). type SecretType string // SecretUpdate defines model for SecretUpdate. @@ -2834,7 +2863,7 @@ type Task struct { CompletedAt *time.Time `json:"completedAt,omitempty"` CreatedAt time.Time `json:"createdAt"` - // EndpointId Allocated endpoint row, the same UUID as `Endpoint.id`. Present when the live row at `endpointPath` was created at or before this task. Omitted when that path has no live row, when this task has no creation time, and when this task predates the live row: a path removed and added again is a different endpoint, and this id must not name it. Metrics filters take this id, not `endpointPath`. + // EndpointId Allocated endpoint row, the same UUID as `Endpoint.id`. Present when the live row at `endpointPath` was created at or before this task. Omitted when that path has no live row, when this task has no creation time, and when this task predates the live row: a path removed and added again is a different endpoint, and this id must not name it. Read from a cache, so it is best effort: also omitted when the cached endpoint rows are older than this task and could not be read again (a later read returns it), and a removed endpoint's id can still be returned for a short while after the removal. Metrics filters take this id, not `endpointPath`. EndpointId *openapi_types.UUID `json:"endpointId,omitempty"` // EndpointPath Path of the endpoint to route the task to: one or more bare lowercase segments joined by slashes, such as `generate` or `v1/chat/completions`, with no leading or trailing slash. Send those slashes unencoded. A generated client that escapes `/` as `%2F` is rejected with `422`. @@ -2954,7 +2983,7 @@ type UsageEvent struct { WorkerId openapi_types.UUID `json:"workerId"` } -// UsageRegion The region a capacity commitment applies to. One value until app placement selects a region. +// UsageRegion The billing region a capacity commitment applies to, not a region of the region catalog. type UsageRegion string // UsageSummary Aggregated usage for one half-open window. Display amounts carry fractions smaller than one ledger unit across buckets in response order, so their sum equals `total`. @@ -3350,6 +3379,7 @@ type VolumeSettings struct { // Available Effective access including the saved beta switch, tenancy and organization lifecycle. Available bool `json:"available"` Limits VolumeLimits `json:"limits"` + Usage VolumeUsage `json:"usage"` } // VolumeSha256 SHA-256 digest as 64 lowercase hexadecimal characters. @@ -3502,6 +3532,12 @@ type VolumeUploadTargets struct { UploadTargets []VolumeUploadTarget `json:"uploadTargets"` } +// VolumeUsage defines model for VolumeUsage. +type VolumeUsage struct { + // StoredBytes Stored bytes: the plaintext sizes of the distinct files the latest files of the organization's Volumes reference. A file counts once however many Volumes, apps or environments use it, and stops counting when no Volume references it. This is the usage `maxStoredBytes` limits. An upload is admitted against it plus the content unfinished upload sessions hold and the content upload sessions, finished or not, left in storage until cleanup removes it, so an upload can be refused before `storedBytes` reaches `maxStoredBytes`. + StoredBytes int64 `json:"storedBytes"` +} + // VolumeWorkerMount One Shared Volume as a worker mounts it. type VolumeWorkerMount struct { // ManifestSha256 Digest of the file list the worker prepared when it started, the `manifestSha256` the Volume had then. Absent only while the worker is still preparing. @@ -3586,7 +3622,7 @@ type WorkerConfig struct { GpusPerWorker int32 `json:"gpusPerWorker"` Id openapi_types.UUID `json:"id"` - // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. + // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. IdleTtlSecs int32 `json:"idleTtlSecs"` MaxWorkers int32 `json:"maxWorkers"` @@ -3627,7 +3663,7 @@ type WorkerConfigCreate struct { // GpusPerWorker GPUs granted to one worker pod. A worker holds its GPUs as one group the cluster grants indivisibly, so the count is one of 1, 2, 4 or 8. `GET /v1/gpu-types` lists the accepted counts on `GpuType.gpusPerWorker`. A count that list omits is rejected with a 422 naming `/configuration/gpusPerWorker` and detail `must be one of the gpusPerWorker counts GPU type "" serves: `, or `GPU type "" serves no gpusPerWorker count` when the list is empty. A listed count can still be rejected when the cluster has published worker shapes that omit it, with detail `must be one of the worker shapes available for GPU type "": `, or `no multi-GPU worker shape is available for GPU type ""` when that cluster grants none. A cluster that has published no shapes accepts a listed count. `multiGpuSupport` false rejects a count above 1 with detail `GPU type "" does not support multiple GPUs per worker`, or `fallback GPU type "" does not support multiple GPUs per worker` when the fallback type refuses it. A value above 1 requires an image built after the multi-GPU worker entrypoint. Older images serve a single rank while holding every granted GPU. GpusPerWorker *int32 `json:"gpusPerWorker,omitempty"` - // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. + // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. IdleTtlSecs int32 `json:"idleTtlSecs"` MaxWorkers int32 `json:"maxWorkers"` @@ -3662,7 +3698,7 @@ type WorkerConfigPatch struct { // GpusPerWorker GPUs granted to one worker pod. A worker holds its GPUs as one group the cluster grants indivisibly, so the count is one of 1, 2, 4 or 8. `GET /v1/gpu-types` lists the accepted counts on `GpuType.gpusPerWorker`. A count that list omits is rejected with a 422 naming `/configuration/gpusPerWorker` and detail `must be one of the gpusPerWorker counts GPU type "" serves: `, or `GPU type "" serves no gpusPerWorker count` when the list is empty. A listed count can still be rejected when the cluster has published worker shapes that omit it, with detail `must be one of the worker shapes available for GPU type "": `, or `no multi-GPU worker shape is available for GPU type ""` when that cluster grants none. A cluster that has published no shapes accepts a listed count. `multiGpuSupport` false rejects a count above 1 with detail `GPU type "" does not support multiple GPUs per worker`, or `fallback GPU type "" does not support multiple GPUs per worker` when the fallback type refuses it. A value above 1 requires an image built after the multi-GPU worker entrypoint. Older images serve a single rank while holding every granted GPU. GpusPerWorker *int32 `json:"gpusPerWorker,omitempty"` - // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. Omit to leave unchanged. + // IdleTtlSecs Seconds an app at `minWorkers` 0 waits after its last task before it scales to zero, removing every worker still running. A value below 15 is applied as 15. `scalingDelaySecs` can remove workers above one sooner. It has no effect while `minWorkers` is above 0: `scalingDelaySecs` alone decides when workers above `minWorkers` are removed. Omit to leave unchanged. IdleTtlSecs *int32 `json:"idleTtlSecs,omitempty"` MaxWorkers *int32 `json:"maxWorkers,omitempty"` @@ -5586,6 +5622,13 @@ type ClientInterface interface { // Corresponds with PUT /v1/oidc-connectors/{connectorName} (the `UpdateOidcConnector` operationId). UpdateOidcConnector(ctx context.Context, connectorName OidcConnectorName, params *UpdateOidcConnectorParams, body UpdateOidcConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListRegions List regions + // + // Returns the regions the caller's organization may name. The request requires authentication. By default that is `global`, where the platform picks where to run, and every open region. An organization can be limited to fewer regions, or let into a region that is not open yet; then exactly those are listed. The list is small, so the response is the whole list, `global` first, then by `code`. + // + // Corresponds with GET /v1/regions (the `ListRegions` operationId). + ListRegions(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListReservedCapacity Report reserved capacity and its use // // What the authenticated organization has reserved, what it is using of it now, and what overflowed to pay-as-you-go. @@ -5796,9 +5839,9 @@ type ClientInterface interface { // Corresponds with GET /v1/volumes-key-pair (the `GetVolumeKeyPair` operationId). GetVolumeKeyPair(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetVolumeSettings Read Shared Volume access and limits + // GetVolumeSettings Read Shared Volume access, limits and usage // - // Returns effective access and limits for the authenticated organization. The two are read separately, so a change made while the request runs can show access and limits that never held together. This setting does not indicate whether Shared Volume operations are deployed. + // Returns effective access, limits and stored-byte usage for the authenticated organization. The three are read separately, so a change made while the request runs can show values that never held together. This setting does not indicate whether Shared Volume operations are deployed. // // Corresponds with GET /v1/volumes-settings (the `GetVolumeSettings` operationId). GetVolumeSettings(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -7509,6 +7552,23 @@ func (c *Client) UpdateOidcConnector(ctx context.Context, connectorName OidcConn return c.Client.Do(req) } +// ListRegions List regions +// +// Returns the regions the caller's organization may name. The request requires authentication. By default that is `global`, where the platform picks where to run, and every open region. An organization can be limited to fewer regions, or let into a region that is not open yet; then exactly those are listed. The list is small, so the response is the whole list, `global` first, then by `code`. +// +// Corresponds with GET /v1/regions (the `ListRegions` operationId). +func (c *Client) ListRegions(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListRegionsRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + // ListReservedCapacity Report reserved capacity and its use // // What the authenticated organization has reserved, what it is using of it now, and what overflowed to pay-as-you-go. @@ -7959,9 +8019,9 @@ func (c *Client) GetVolumeKeyPair(ctx context.Context, reqEditors ...RequestEdit return c.Client.Do(req) } -// GetVolumeSettings Read Shared Volume access and limits +// GetVolumeSettings Read Shared Volume access, limits and usage // -// Returns effective access and limits for the authenticated organization. The two are read separately, so a change made while the request runs can show access and limits that never held together. This setting does not indicate whether Shared Volume operations are deployed. +// Returns effective access, limits and stored-byte usage for the authenticated organization. The three are read separately, so a change made while the request runs can show values that never held together. This setting does not indicate whether Shared Volume operations are deployed. // // Corresponds with GET /v1/volumes-settings (the `GetVolumeSettings` operationId). func (c *Client) GetVolumeSettings(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -12647,6 +12707,33 @@ func NewUpdateOidcConnectorRequestWithBody(server string, connectorName OidcConn return req, nil } +// NewListRegionsRequest constructs an http.Request for the ListRegions method +func NewListRegionsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/regions") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodGet, queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewListReservedCapacityRequest constructs an http.Request for the ListReservedCapacity method func NewListReservedCapacityRequest(server string, params *ListReservedCapacityParams) (*http.Request, error) { var err error @@ -15622,6 +15709,15 @@ type ClientWithResponsesInterface interface { // Corresponds with PUT /v1/oidc-connectors/{connectorName} (the `UpdateOidcConnector` operationId). UpdateOidcConnectorWithResponse(ctx context.Context, connectorName OidcConnectorName, params *UpdateOidcConnectorParams, body UpdateOidcConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOidcConnectorResponse, error) + // ListRegionsWithResponse List regions + // + // Returns the regions the caller's organization may name. The request requires authentication. By default that is `global`, where the platform picks where to run, and every open region. An organization can be limited to fewer regions, or let into a region that is not open yet; then exactly those are listed. The list is small, so the response is the whole list, `global` first, then by `code`. + // + // Returns a wrapper object for the known response body format(s). + // + // Corresponds with GET /v1/regions (the `ListRegions` operationId). + ListRegionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListRegionsResponse, error) + // ListReservedCapacityWithResponse Report reserved capacity and its use // // What the authenticated organization has reserved, what it is using of it now, and what overflowed to pay-as-you-go. @@ -15856,9 +15952,9 @@ type ClientWithResponsesInterface interface { // Corresponds with GET /v1/volumes-key-pair (the `GetVolumeKeyPair` operationId). GetVolumeKeyPairWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetVolumeKeyPairResponse, error) - // GetVolumeSettingsWithResponse Read Shared Volume access and limits + // GetVolumeSettingsWithResponse Read Shared Volume access, limits and usage // - // Returns effective access and limits for the authenticated organization. The two are read separately, so a change made while the request runs can show access and limits that never held together. This setting does not indicate whether Shared Volume operations are deployed. + // Returns effective access, limits and stored-byte usage for the authenticated organization. The three are read separately, so a change made while the request runs can show values that never held together. This setting does not indicate whether Shared Volume operations are deployed. // // Returns a wrapper object for the known response body format(s). // @@ -22002,6 +22098,68 @@ func (r UpdateOidcConnectorResponse) ContentType() string { return "" } +type ListRegionsResponse struct { + Body []byte + HTTPResponse *http.Response + // JSON200 the response for an HTTP 200 `application/json` response + JSON200 *RegionList + // ApplicationproblemJSON401 the response for an HTTP 401 `application/problem+json` response + ApplicationproblemJSON401 *Unauthorized + // ApplicationproblemJSON500 the response for an HTTP 500 `application/problem+json` response + ApplicationproblemJSON500 *InternalServerError + // ApplicationproblemJSON503 the response for an HTTP 503 `application/problem+json` response + ApplicationproblemJSON503 *ServiceUnavailable +} + +// GetJSON200 returns the response for an HTTP 200 `application/json` response +func (r ListRegionsResponse) GetJSON200() *RegionList { + return r.JSON200 +} + +// GetApplicationproblemJSON401 returns the response for an HTTP 401 `application/problem+json` response +func (r ListRegionsResponse) GetApplicationproblemJSON401() *Unauthorized { + return r.ApplicationproblemJSON401 +} + +// GetApplicationproblemJSON500 returns the response for an HTTP 500 `application/problem+json` response +func (r ListRegionsResponse) GetApplicationproblemJSON500() *InternalServerError { + return r.ApplicationproblemJSON500 +} + +// GetApplicationproblemJSON503 returns the response for an HTTP 503 `application/problem+json` response +func (r ListRegionsResponse) GetApplicationproblemJSON503() *ServiceUnavailable { + return r.ApplicationproblemJSON503 +} + +// GetBody returns the raw response body bytes +func (r ListRegionsResponse) GetBody() []byte { + return r.Body +} + +// Status returns HTTPResponse.Status +func (r ListRegionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ListRegionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// ContentType is a convenience method to retrieve the Content-Type value from the HTTP response headers +func (r ListRegionsResponse) ContentType() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Header.Get("Content-Type") + } + return "" +} + type ListReservedCapacityResponse struct { Body []byte HTTPResponse *http.Response @@ -26211,6 +26369,21 @@ func (c *ClientWithResponses) UpdateOidcConnectorWithResponse(ctx context.Contex return ParseUpdateOidcConnectorResponse(rsp) } +// ListRegionsWithResponse List regions +// +// Returns the regions the caller's organization may name. The request requires authentication. By default that is `global`, where the platform picks where to run, and every open region. An organization can be limited to fewer regions, or let into a region that is not open yet; then exactly those are listed. The list is small, so the response is the whole list, `global` first, then by `code`. +// +// Returns a wrapper object for the known response body format(s). +// +// Corresponds with GET /v1/regions (the `ListRegions` operationId). +func (c *ClientWithResponses) ListRegionsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListRegionsResponse, error) { + rsp, err := c.ListRegions(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseListRegionsResponse(rsp) +} + // ListReservedCapacityWithResponse Report reserved capacity and its use // // What the authenticated organization has reserved, what it is using of it now, and what overflowed to pay-as-you-go. @@ -26589,9 +26762,9 @@ func (c *ClientWithResponses) GetVolumeKeyPairWithResponse(ctx context.Context, return ParseGetVolumeKeyPairResponse(rsp) } -// GetVolumeSettingsWithResponse Read Shared Volume access and limits +// GetVolumeSettingsWithResponse Read Shared Volume access, limits and usage // -// Returns effective access and limits for the authenticated organization. The two are read separately, so a change made while the request runs can show access and limits that never held together. This setting does not indicate whether Shared Volume operations are deployed. +// Returns effective access, limits and stored-byte usage for the authenticated organization. The three are read separately, so a change made while the request runs can show values that never held together. This setting does not indicate whether Shared Volume operations are deployed. // // Returns a wrapper object for the known response body format(s). // @@ -31958,6 +32131,53 @@ func ParseUpdateOidcConnectorResponse(rsp *http.Response) (*UpdateOidcConnectorR return response, nil } +// ParseListRegionsResponse parses an HTTP response from a ListRegionsWithResponse call +func ParseListRegionsResponse(rsp *http.Response) (*ListRegionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListRegionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RegionList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Unauthorized + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest InternalServerError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSON500 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503: + var dest ServiceUnavailable + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.ApplicationproblemJSON503 = &dest + + } + + return response, nil +} + // ParseListReservedCapacityResponse parses an HTTP response from a ListReservedCapacityWithResponse call func ParseListReservedCapacityResponse(rsp *http.Response) (*ListReservedCapacityResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) From 2e2332e41b5d3088a8251b47c8ea639f25f3649b Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Mon, 30 Nov 2026 17:22:22 +0100 Subject: [PATCH 2/9] feat(serverless): add volumes usage runware serverless volumes usage shows the organization's stored bytes against its stored-byte limit, read from the Shared Volume settings, in a table or with --format json or yaml. The table adds a note on stderr that files shared between Volumes count once, so the sizes volumes list shows can add up to more than the stored bytes, and that the list covers one environment while the stored bytes cover all of them. Like volumes settings, it exits non-zero when Shared Volumes are not enabled for the organization, after printing the usage when the API reports it. The command stays hidden with the rest of the volumes group. An overlay action makes the settings' usage optional in the generated client. Required, it would decode as zero from a response without it, and the command would print that zero as the organization's usage; the command fails instead. --- api/serverless/overlay.yaml | 6 + internal/api/serverless/gen/client.gen.go | 2 +- internal/api/serverless/volumes.go | 10 +- internal/cmd/serverless/volumes.go | 1 + internal/cmd/serverless/volumes_display.go | 19 +++ internal/cmd/serverless/volumes_manage.go | 66 ++++++++- .../cmd/serverless/volumes_manage_test.go | 138 +++++++++++++++++- 7 files changed, 232 insertions(+), 10 deletions(-) diff --git a/api/serverless/overlay.yaml b/api/serverless/overlay.yaml index b70dfe0..84ab62c 100644 --- a/api/serverless/overlay.yaml +++ b/api/serverless/overlay.yaml @@ -11,3 +11,9 @@ actions: # this action once every deployed API sends servingWorkers. - target: $.components.schemas.AppRuntime.required[?(@ == 'servingWorkers')] remove: true + # The same for the Shared Volume settings' usage: required, it would decode + # as zero stored bytes from an API that does not send it, and 'volumes + # usage' would print that zero as the organization's usage. Remove this + # action once every deployed API sends usage. + - target: $.components.schemas.VolumeSettings.required[?(@ == 'usage')] + remove: true diff --git a/internal/api/serverless/gen/client.gen.go b/internal/api/serverless/gen/client.gen.go index a7ec39b..720a53d 100644 --- a/internal/api/serverless/gen/client.gen.go +++ b/internal/api/serverless/gen/client.gen.go @@ -3379,7 +3379,7 @@ type VolumeSettings struct { // Available Effective access including the saved beta switch, tenancy and organization lifecycle. Available bool `json:"available"` Limits VolumeLimits `json:"limits"` - Usage VolumeUsage `json:"usage"` + Usage *VolumeUsage `json:"usage,omitempty"` } // VolumeSha256 SHA-256 digest as 64 lowercase hexadecimal characters. diff --git a/internal/api/serverless/volumes.go b/internal/api/serverless/volumes.go index a557805..dada3cf 100644 --- a/internal/api/serverless/volumes.go +++ b/internal/api/serverless/volumes.go @@ -53,8 +53,8 @@ type VolumeFile = gen.VolumeFile // file list it was read from. type VolumeFilePage = gen.VolumeFilePage -// VolumeSettings are the organization's Shared Volume access and effective -// limits. +// VolumeSettings are the organization's Shared Volume access, effective +// limits and stored-byte usage. type VolumeSettings = gen.VolumeSettings // GetVolumeReferencesParams are the query parameters for getVolumeReferences. @@ -251,9 +251,9 @@ func (c *Client) ListVolumeFiles(ctx context.Context, name string, params ListVo return resp.JSON200, nil } -// GetVolumeSettings returns the organization's Shared Volume access and -// effective limits. Settings belong to the organization, so the request -// carries no environment. +// GetVolumeSettings returns the organization's Shared Volume access, +// effective limits and stored-byte usage. Settings belong to the +// organization, so the request carries no environment. func (c *Client) GetVolumeSettings(ctx context.Context) (*VolumeSettings, error) { if c.apiKey == "" { return nil, transport.ErrNoAPIKey diff --git a/internal/cmd/serverless/volumes.go b/internal/cmd/serverless/volumes.go index 53560e5..154d0ff 100644 --- a/internal/cmd/serverless/volumes.go +++ b/internal/cmd/serverless/volumes.go @@ -86,6 +86,7 @@ func newVolumesCmd(logger *log.Logger) *cobra.Command { newVolumesFilesCmd(logger), newVolumesPutCmd(logger), newVolumesSettingsCmd(logger), + newVolumesUsageCmd(logger), ) return cmd } diff --git a/internal/cmd/serverless/volumes_display.go b/internal/cmd/serverless/volumes_display.go index 8569e9f..c70ff12 100644 --- a/internal/cmd/serverless/volumes_display.go +++ b/internal/cmd/serverless/volumes_display.go @@ -24,6 +24,7 @@ const ( colDeleted = "Deleted" colLostRollback = "Lost rollback" colAvailable = "Enabled" + colStored = "Stored" colMaxStored = "Max stored" colMaxFileSize = "Max file size" colMaxFiles = "Max files per Volume" @@ -240,3 +241,21 @@ func (r volumeSettingsResult) Rows() [][]any { func (r volumeSettingsResult) MarshalJSON() ([]byte, error) { return json.Marshal(serverlessapi.VolumeSettings(r)) } + +// volumeUsageResult is the organization's Shared Volume storage against its +// limit. +type volumeUsageResult struct { + StoredBytes int64 `json:"storedBytes"` + MaxStoredBytes int64 `json:"maxStoredBytes"` +} + +func (r volumeUsageResult) Headers() []string { + return []string{colField, colValue} +} + +func (r volumeUsageResult) Rows() [][]any { + return [][]any{ + {colStored, humanBytes(r.StoredBytes)}, + {colMaxStored, humanBytes(r.MaxStoredBytes)}, + } +} diff --git a/internal/cmd/serverless/volumes_manage.go b/internal/cmd/serverless/volumes_manage.go index e1ba5be..e8903a4 100644 --- a/internal/cmd/serverless/volumes_manage.go +++ b/internal/cmd/serverless/volumes_manage.go @@ -27,8 +27,18 @@ const ( var errNothingToUpdateOnVolume = errors.New("nothing to update; pass --description or --clear description") -// errVolumesNotEnabled makes 'volumes settings' exit non-zero, after printing -// the settings, for an organization without Shared Volumes. +// errVolumeUsageMissing is returned when the settings the API answered with +// carry no usage for an organization with Shared Volumes, so 'volumes usage' +// never prints zero stored bytes for it. +var errVolumeUsageMissing = errors.New("the API did not report the organization's stored bytes") + +// volumeUsageNote says why the Volume sizes 'volumes list' shows do not add up +// to the stored bytes. +const volumeUsageNote = "Files shared between Volumes count once, so adding up the sizes 'volumes list' shows can give more than Stored; that list also covers one environment, and Stored covers all of them." + +// errVolumesNotEnabled makes 'volumes settings' and 'volumes usage' exit +// non-zero, after printing what they can, for an organization without Shared +// Volumes. var errVolumesNotEnabled = errors.New("this organization does not have Shared Volumes enabled") // volumesHelpLong is the help of the volumes group. @@ -495,6 +505,58 @@ func newVolumesSettingsCmd(logger *log.Logger) *cobra.Command { } } +func newVolumesUsageCmd(logger *log.Logger) *cobra.Command { + return &cobra.Command{ + Use: "usage", + Short: "Show the organization's Shared Volume storage against its limit", + Long: `Show the bytes the organization's Volumes store, against its stored-byte limit. + +A file counts once however many Volumes, apps or environments use it, so the +Volume sizes 'volumes list' shows can add up to more than the stored bytes. +That list also covers one environment, and the stored bytes cover all of them. + +An upload can be refused before the stored bytes reach the limit: content that +upload sessions hold, open or not yet cleaned up, counts against it too. + +Like 'volumes settings', it exits non-zero when Shared Volumes are not enabled +for the organization, after printing the usage when the API reports it.`, + Example: ` runware serverless volumes usage + runware serverless volumes usage --format json`, + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + spin := cmdutil.NewSpinner("Fetching Shared Volume usage...") + spin.Start() + + settings, err := newServerlessClient(cmd, logger).GetVolumeSettings(cmd.Context()) + spin.Stop() + if err != nil { + return err + } + if settings.Usage == nil { + if !settings.Available { + return errVolumesNotEnabled + } + return errVolumeUsageMissing + } + + format := cmdutil.FormatFor(cmd) + if err := output.Print(format, volumeUsageResult{ + StoredBytes: settings.Usage.StoredBytes, + MaxStoredBytes: settings.Limits.MaxStoredBytes, + }); err != nil { + return err + } + if format == output.FormatTable { + _, _ = fmt.Fprintln(cmd.ErrOrStderr(), volumeUsageNote) + } + if !settings.Available { + return errVolumesNotEnabled + } + return nil + }, + } +} + // volumeNameArg takes one argument, a Volume name the API accepts. func volumeNameArg(cmd *cobra.Command, args []string) error { if err := cobra.ExactArgs(1)(cmd, args); err != nil { diff --git a/internal/cmd/serverless/volumes_manage_test.go b/internal/cmd/serverless/volumes_manage_test.go index af6a150..7a0fe95 100644 --- a/internal/cmd/serverless/volumes_manage_test.go +++ b/internal/cmd/serverless/volumes_manage_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "io" + "maps" "net/http" "net/http/httptest" "net/url" @@ -72,7 +73,9 @@ const ( testRetryAfterRelease = "retry after the API release that adds it" testBlockingReferences = `{"blocking":[{"appId":"img-gen","appVersionNumber":7,"kind":"current-app-version"}],"rollbackTargets":[{"appId":"img-gen","appVersionNumber":3,"kind":"rollback-target"}]}` testRollbackReferences = `{"blocking":[],"rollbackTargets":[{"appId":"img-gen","appVersionNumber":3,"kind":"rollback-target"}]}` - testSettingsEnabled = `{"available":true,"limits":{"maxStoredBytes":1099511627776,"maxFileBytes":268435456000,"maxFilesPerVolume":100000,"maxMountedBytesPerAppVersion":536870912000,"uploadSessionTtlSeconds":86400}}` + testSettingsEnabled = `{"available":true,"limits":{"maxStoredBytes":1099511627776,"maxFileBytes":268435456000,"maxFilesPerVolume":100000,"maxMountedBytesPerAppVersion":536870912000,"uploadSessionTtlSeconds":86400},"usage":{"storedBytes":12884901888}}` + testSettingsWithoutUsage = `{"available":true,"limits":{"maxStoredBytes":1099511627776,"maxFileBytes":268435456000,"maxFilesPerVolume":100000,"maxMountedBytesPerAppVersion":536870912000,"uploadSessionTtlSeconds":86400}}` + testSettingsDisabledWithUsage = `{"available":false,"limits":{"maxStoredBytes":1099511627776,"maxFileBytes":268435456000,"maxFilesPerVolume":100000,"maxMountedBytesPerAppVersion":268435456000,"uploadSessionTtlSeconds":86400},"usage":{"storedBytes":0}}` testSettingsDisabled = `{"available":false,"limits":{"maxStoredBytes":1099511627776,"maxFileBytes":268435456000,"maxFilesPerVolume":100000,"maxMountedBytesPerAppVersion":268435456000,"uploadSessionTtlSeconds":86400}}` testNotImplemented = `{"type":"https://docs.runware.ai/serverless/errors#not-implemented","title":"Not Implemented","status":501,"detail":"Not Implemented"}` testNoRoute = `{"type":"https://docs.runware.ai/serverless/errors#not-found","title":"Not Found","status":404,"detail":"no route matches the request path"}` @@ -1056,6 +1059,137 @@ func TestVolumesSettingsTakesNoEnvironment(t *testing.T) { } } +func TestVolumesUsageShowsStoredBytesAgainstTheLimit(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsEnabled), + }) + + run := runVolumesTable(t, api, testUsageCommand) + + if run.err != nil { + t.Fatal(run.err) + } + requireRow(t, run.stdout, colStored, "12.0 GiB") + requireRow(t, run.stdout, colMaxStored, "1.0 TiB") + requireOutput(t, run.stderr, volumeUsageNote) + if strings.Contains(run.stdout, colAvailable) { + t.Fatalf("usage shows access, which belongs to settings:\n%s", run.stdout) + } +} + +func TestVolumesUsageFailsAfterPrintingWhenNotEnabled(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsDisabledWithUsage), + }) + + run := runVolumesTable(t, api, testUsageCommand) + + if !errors.Is(run.err, errVolumesNotEnabled) { + t.Fatalf("err = %v, want %v", run.err, errVolumesNotEnabled) + } + requireRow(t, run.stdout, colStored, "0 B") + requireRow(t, run.stdout, colMaxStored, "1.0 TiB") + + run = runVolumes(t, api, testFormatJSON, strings.NewReader(""), testUsageCommand) + + if !errors.Is(run.err, errVolumesNotEnabled) { + t.Fatalf("JSON err = %v, want %v", run.err, errVolumesNotEnabled) + } + var got volumeUsageResult + if err := json.Unmarshal([]byte(run.stdout), &got); err != nil { + t.Fatalf("JSON output did not print the usage before failing: %v\n%s", err, run.stdout) + } +} + +// An API without usage must not hide that Shared Volumes are not enabled. +func TestVolumesUsageSaysNotEnabledWhenTheAPISendsNoUsage(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsDisabled), + }) + + run := runVolumesTable(t, api, testUsageCommand) + + if !errors.Is(run.err, errVolumesNotEnabled) { + t.Fatalf("err = %v, want %v", run.err, errVolumesNotEnabled) + } + if run.stdout != "" { + t.Fatalf("usage printed output without the API's usage:\n%s", run.stdout) + } +} + +func TestVolumesUsageYAMLKeepsBytes(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsEnabled), + }) + + run := runVolumes(t, api, testFormatYAML, strings.NewReader(""), testUsageCommand) + + if run.err != nil { + t.Fatal(run.err) + } + var got map[string]int64 + if err := yaml.Unmarshal([]byte(run.stdout), &got); err != nil { + t.Fatalf("decode: %v\n%s", err, run.stdout) + } + want := map[string]int64{ + "storedBytes": 12884901888, + "maxStoredBytes": 1099511627776, + } + if !maps.Equal(got, want) { + t.Fatalf("usage = %v, want %v", got, want) + } +} + +func TestVolumesUsageJSONKeepsBytes(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsEnabled), + }) + + run := runVolumes(t, api, testFormatJSON, strings.NewReader(""), testUsageCommand) + + if run.err != nil { + t.Fatal(run.err) + } + var got volumeUsageResult + if err := json.Unmarshal([]byte(run.stdout), &got); err != nil { + t.Fatalf("decode: %v\n%s", err, run.stdout) + } + want := volumeUsageResult{ + StoredBytes: 12884901888, + MaxStoredBytes: 1099511627776, + } + if got != want { + t.Fatalf("usage = %+v, want %+v", got, want) + } + if strings.Contains(run.stderr, volumeUsageNote) { + t.Fatalf("JSON output printed the table note on stderr:\n%s", run.stderr) + } +} + +// Settings without usage must not print zero stored bytes. +func TestVolumesUsageFailsWhenTheAPISendsNoUsage(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsWithoutUsage), + }) + + run := runVolumesTable(t, api, testUsageCommand) + + if !errors.Is(run.err, errVolumeUsageMissing) { + t.Fatalf("err = %v, want %v", run.err, errVolumeUsageMissing) + } + if run.stdout != "" { + t.Fatalf("usage printed output without the API's usage:\n%s", run.stdout) + } +} + +func TestVolumesUsageTakesNoEnvironment(t *testing.T) { + withDefaultEnvironment(t, testEnvironment) + cmd := newVolumesUsageCmd(log.New(io.Discard)) + if cmd.Flags().Lookup(environmentFlag) != nil { + t.Fatal("usage takes --env, but usage belongs to the organization") + } +} + // volumeEnvironmentCommands are the Volume commands that address one // environment, with the requests they send. func volumeEnvironmentCommands() map[string][]string { @@ -1392,7 +1526,7 @@ func TestVolumesGroupHoldsPutAndTheManagementCommands(t *testing.T) { for _, sub := range cmd.Commands() { names = append(names, sub.Name()) } - want := []string{createCommand, testDeleteCommand, testFilesCommand, appHealthListCommand, "put", testReferencesCommand, "settings", appHealthShowCommand, testUpdateCommand} + want := []string{createCommand, testDeleteCommand, testFilesCommand, appHealthListCommand, "put", testReferencesCommand, "settings", appHealthShowCommand, testUpdateCommand, testUsageCommand} if !slices.Equal(names, want) { t.Fatalf("commands = %v, want %v", names, want) } From a7ee9fc14f84e97bc55044997ad4f9f6495a6f50 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Mon, 30 Nov 2026 17:23:05 +0100 Subject: [PATCH 3/9] fix(serverless): keep volumes settings to access and limits The settings response now carries the organization's usage, which volumes usage shows. volumes settings drops it from its JSON and YAML, so it keeps printing access and limits only, as its table does. --- internal/cmd/serverless/volumes_display.go | 6 ++++- .../cmd/serverless/volumes_manage_test.go | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/cmd/serverless/volumes_display.go b/internal/cmd/serverless/volumes_display.go index c70ff12..72a7d62 100644 --- a/internal/cmd/serverless/volumes_display.go +++ b/internal/cmd/serverless/volumes_display.go @@ -220,6 +220,8 @@ func (r volumeDeletedResult) Rows() [][]any { } // volumeSettingsResult is the organization's Shared Volume access and limits. +// JSON and YAML print the API's settings without the usage, which 'volumes +// usage' shows. type volumeSettingsResult serverlessapi.VolumeSettings func (r volumeSettingsResult) Headers() []string { @@ -239,7 +241,9 @@ func (r volumeSettingsResult) Rows() [][]any { } func (r volumeSettingsResult) MarshalJSON() ([]byte, error) { - return json.Marshal(serverlessapi.VolumeSettings(r)) + settings := serverlessapi.VolumeSettings(r) + settings.Usage = nil + return json.Marshal(settings) } // volumeUsageResult is the organization's Shared Volume storage against its diff --git a/internal/cmd/serverless/volumes_manage_test.go b/internal/cmd/serverless/volumes_manage_test.go index 7a0fe95..6f29765 100644 --- a/internal/cmd/serverless/volumes_manage_test.go +++ b/internal/cmd/serverless/volumes_manage_test.go @@ -1051,6 +1051,28 @@ func TestVolumesSettingsFailsAfterPrintingWhenNotEnabled(t *testing.T) { requireRow(t, run.stdout, colMaxMounted, "250.0 GiB") } +func TestVolumesSettingsJSONLeavesUsageToUsage(t *testing.T) { + api := newVolumeAPI(t, map[string][]stubResponse{ + "GET " + testVolumeSettings: ok(testSettingsEnabled), + }) + + run := runVolumes(t, api, testFormatJSON, strings.NewReader(""), "settings") + + if run.err != nil { + t.Fatal(run.err) + } + var got serverlessapi.VolumeSettings + if err := json.Unmarshal([]byte(run.stdout), &got); err != nil { + t.Fatalf("decode: %v\n%s", err, run.stdout) + } + if got.Usage != nil { + t.Fatalf("settings prints the usage, which 'volumes usage' shows:\n%s", run.stdout) + } + if got.Limits.MaxStoredBytes == 0 { + t.Fatalf("settings lacks the limits:\n%s", run.stdout) + } +} + func TestVolumesSettingsTakesNoEnvironment(t *testing.T) { withDefaultEnvironment(t, testEnvironment) cmd := newVolumesSettingsCmd(log.New(io.Discard)) From de8d9873e4480230750e701b50fb10f611d49d25 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Mon, 30 Nov 2026 17:30:07 +0100 Subject: [PATCH 4/9] fix(serverless): keep an app's regions omitted when the API omits them The synced spec makes an app's regions required, so the generated type decoded a response without them as a nil list and apps commands printed "regions": null in JSON and YAML. An overlay action makes the field optional for this client, as for servingWorkers, so it stays omitted. --- api/serverless/overlay.yaml | 5 +++++ internal/api/serverless/gen/client.gen.go | 2 +- internal/cmd/serverless/display_test.go | 25 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/api/serverless/overlay.yaml b/api/serverless/overlay.yaml index 84ab62c..a1f1a5a 100644 --- a/api/serverless/overlay.yaml +++ b/api/serverless/overlay.yaml @@ -11,6 +11,11 @@ actions: # this action once every deployed API sends servingWorkers. - target: $.components.schemas.AppRuntime.required[?(@ == 'servingWorkers')] remove: true + # The same for an app's regions: required, they would print as null from an + # API that does not send them. Remove this action once every deployed API + # sends regions. + - target: $.components.schemas.App.required[?(@ == 'regions')] + remove: true # The same for the Shared Volume settings' usage: required, it would decode # as zero stored bytes from an API that does not send it, and 'volumes # usage' would print that zero as the organization's usage. Remove this diff --git a/internal/api/serverless/gen/client.gen.go b/internal/api/serverless/gen/client.gen.go index 720a53d..69e2a28 100644 --- a/internal/api/serverless/gen/client.gen.go +++ b/internal/api/serverless/gen/client.gen.go @@ -1412,7 +1412,7 @@ type App struct { Mounts *[]VolumeMount `json:"mounts,omitempty"` // Regions Where the app runs: `["global"]` when the create named no region, else the region it named or the app was pinned to. - Regions AppRegions `json:"regions"` + Regions *AppRegions `json:"regions,omitempty"` // Runtime Observed state for one app at `calculatedAt`. Desired worker scale remains in `configuration`. Worker and GPU counts are always present. Traffic, duration, and queue fields are omitted when their backing data is unavailable. Runtime AppRuntime `json:"runtime"` diff --git a/internal/cmd/serverless/display_test.go b/internal/cmd/serverless/display_test.go index cf01099..5f3c1d2 100644 --- a/internal/cmd/serverless/display_test.go +++ b/internal/cmd/serverless/display_test.go @@ -799,6 +799,31 @@ func TestWorkerResult_NilOptionalFields(t *testing.T) { } } +// An API that does not send an app's regions yet must not print them as null in +// JSON and YAML; one that sends them keeps them. +func TestAppResultKeepsOmittedRegionsOmitted(t *testing.T) { + for _, tc := range []struct { + name, regions, want string + }{ + {"omitted", ``, `"regions"`}, + {"sent", `,"regions":["global"]`, `"regions":["global"]`}, + } { + t.Run(tc.name, func(t *testing.T) { + var app serverlessapi.App + if err := json.Unmarshal([]byte(`{"appId":"`+testAppID+`"`+tc.regions+`}`), &app); err != nil { + t.Fatalf("decode: %v", err) + } + out, err := json.Marshal(appResult(app)) + if err != nil { + t.Fatalf("encode: %v", err) + } + if got, sent := strings.Contains(string(out), tc.want), tc.regions != ""; got != sent { + t.Fatalf("output = %s, want %s printed: %v", out, tc.want, sent) + } + }) + } +} + // An API that does not send servingWorkers yet must not print a zero count in // JSON and YAML; one that sends zero keeps it. func TestAppResultKeepsAnOmittedServingWorkersOmitted(t *testing.T) { From 451297f7e9a24b2911ac60c8a15c98194690763a Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Mon, 30 Nov 2026 20:08:41 +0100 Subject: [PATCH 5/9] test(serverless): name the app regions test cases Follows the convention for named types and one field per line in struct literals. --- internal/cmd/serverless/display_test.go | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/internal/cmd/serverless/display_test.go b/internal/cmd/serverless/display_test.go index 5f3c1d2..5aaef38 100644 --- a/internal/cmd/serverless/display_test.go +++ b/internal/cmd/serverless/display_test.go @@ -799,14 +799,30 @@ func TestWorkerResult_NilOptionalFields(t *testing.T) { } } +// appRegionsCase is one app response for TestAppResultKeepsOmittedRegionsOmitted. +type appRegionsCase struct { + name string + // regions is the regions member appended to the app's JSON, or empty to + // omit it. + regions string + // want is what the output holds exactly when regions is sent. + want string +} + // An API that does not send an app's regions yet must not print them as null in // JSON and YAML; one that sends them keeps them. func TestAppResultKeepsOmittedRegionsOmitted(t *testing.T) { - for _, tc := range []struct { - name, regions, want string - }{ - {"omitted", ``, `"regions"`}, - {"sent", `,"regions":["global"]`, `"regions":["global"]`}, + for _, tc := range []appRegionsCase{ + { + name: "omitted", + regions: ``, + want: `"regions"`, + }, + { + name: "sent", + regions: `,"regions":["global"]`, + want: `"regions":["global"]`, + }, } { t.Run(tc.name, func(t *testing.T) { var app serverlessapi.App From 0b75ad8c66b336fea660be979482c9efd22f2c11 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Tue, 1 Dec 2026 12:40:22 +0100 Subject: [PATCH 6/9] test(serverless): pin the usage note and the settings rows volumes usage --format yaml must not print the table note on stderr, and the volumes settings table must not gain the Stored row that volumes usage owns. --- internal/cmd/serverless/volumes_manage_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/cmd/serverless/volumes_manage_test.go b/internal/cmd/serverless/volumes_manage_test.go index 6f29765..7b675db 100644 --- a/internal/cmd/serverless/volumes_manage_test.go +++ b/internal/cmd/serverless/volumes_manage_test.go @@ -248,6 +248,18 @@ func requireRow(t *testing.T, out string, want ...string) { t.Errorf("no line has all of %q:\n%s", want, out) } +// refuteRow fails when a row of the table out starts with label, so a table +// cannot gain a row another command owns. +func refuteRow(t *testing.T, out, label string) { + t.Helper() + for line := range strings.SplitSeq(out, "\n") { + if strings.HasPrefix(strings.TrimLeft(line, "│ "), label) { + t.Errorf("output has a %q row:\n%s", label, out) + return + } + } +} + func containsAll(s string, want []string) bool { for _, w := range want { if !strings.Contains(s, w) { @@ -1035,6 +1047,7 @@ func TestVolumesSettingsShowsAccessAndLimits(t *testing.T) { requireRow(t, run.stdout, colMaxFiles, "100000") requireRow(t, run.stdout, colMaxMounted, "500.0 GiB") requireRow(t, run.stdout, colUploadDeadline, "24h0m0s") + refuteRow(t, run.stdout, colStored) } func TestVolumesSettingsFailsAfterPrintingWhenNotEnabled(t *testing.T) { @@ -1160,6 +1173,9 @@ func TestVolumesUsageYAMLKeepsBytes(t *testing.T) { if !maps.Equal(got, want) { t.Fatalf("usage = %v, want %v", got, want) } + if strings.Contains(run.stderr, volumeUsageNote) { + t.Fatalf("YAML output printed the table note on stderr:\n%s", run.stderr) + } } func TestVolumesUsageJSONKeepsBytes(t *testing.T) { From 89c07bc6bede71732c2f886de0c9e4bc6993a0c3 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Tue, 1 Dec 2026 12:40:42 +0100 Subject: [PATCH 7/9] refactor(serverless): write the volumes usage count-once rule once The usage help now holds volumeUsageNote as its paragraph instead of restating the rule in other words, so the two cannot drift apart. --- internal/cmd/serverless/volumes_manage.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/cmd/serverless/volumes_manage.go b/internal/cmd/serverless/volumes_manage.go index e8903a4..fbc3f04 100644 --- a/internal/cmd/serverless/volumes_manage.go +++ b/internal/cmd/serverless/volumes_manage.go @@ -33,8 +33,11 @@ var errNothingToUpdateOnVolume = errors.New("nothing to update; pass --descripti var errVolumeUsageMissing = errors.New("the API did not report the organization's stored bytes") // volumeUsageNote says why the Volume sizes 'volumes list' shows do not add up -// to the stored bytes. -const volumeUsageNote = "Files shared between Volumes count once, so adding up the sizes 'volumes list' shows can give more than Stored; that list also covers one environment, and Stored covers all of them." +// to the stored bytes. The usage table prints it on stderr, and the usage help +// holds it as a paragraph, so the rule is written once. +const volumeUsageNote = `A file counts once however many Volumes, apps or environments use it, so +adding up the sizes 'volumes list' shows can give more than Stored. That list +also covers one environment, and Stored covers all of them.` // errVolumesNotEnabled makes 'volumes settings' and 'volumes usage' exit // non-zero, after printing what they can, for an organization without Shared @@ -509,14 +512,13 @@ func newVolumesUsageCmd(logger *log.Logger) *cobra.Command { return &cobra.Command{ Use: "usage", Short: "Show the organization's Shared Volume storage against its limit", - Long: `Show the bytes the organization's Volumes store, against its stored-byte limit. + Long: `Show the bytes the organization's Volumes store (Stored), against its +stored-byte limit (Max stored). -A file counts once however many Volumes, apps or environments use it, so the -Volume sizes 'volumes list' shows can add up to more than the stored bytes. -That list also covers one environment, and the stored bytes cover all of them. +` + volumeUsageNote + ` -An upload can be refused before the stored bytes reach the limit: content that -upload sessions hold, open or not yet cleaned up, counts against it too. +An upload can be refused before Stored reaches the limit: content that upload +sessions hold, open or not yet cleaned up, counts against it too. Like 'volumes settings', it exits non-zero when Shared Volumes are not enabled for the organization, after printing the usage when the API reports it.`, From ed2d063231ab4384d568f9136b778cb635d31372 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Tue, 1 Dec 2026 12:41:59 +0100 Subject: [PATCH 8/9] feat(serverless): show the free bytes in the volumes usage table Stored and Max stored are each rounded, so near the limit they can read the same while some space is left, or differ by a rounding step while none is. A Free row shows the limit minus Stored, and zero once Stored reaches or passes the limit. JSON and YAML keep their shape: they already carry the exact bytes. Free is an upper bound, since content held by upload sessions also counts at admission, so that caveat moves from the help alone into the note the table prints on stderr. --- internal/cmd/serverless/volumes_display.go | 10 ++++ internal/cmd/serverless/volumes_manage.go | 16 ++++--- .../cmd/serverless/volumes_manage_test.go | 48 +++++++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/internal/cmd/serverless/volumes_display.go b/internal/cmd/serverless/volumes_display.go index 72a7d62..5f90523 100644 --- a/internal/cmd/serverless/volumes_display.go +++ b/internal/cmd/serverless/volumes_display.go @@ -25,6 +25,7 @@ const ( colLostRollback = "Lost rollback" colAvailable = "Enabled" colStored = "Stored" + colFree = "Free" colMaxStored = "Max stored" colMaxFileSize = "Max file size" colMaxFiles = "Max files per Volume" @@ -257,9 +258,18 @@ func (r volumeUsageResult) Headers() []string { return []string{colField, colValue} } +// Rows add the free bytes, so a table reader near the limit sees the headroom +// that the two rounded sizes hide. JSON and YAML keep the exact bytes instead. func (r volumeUsageResult) Rows() [][]any { return [][]any{ {colStored, humanBytes(r.StoredBytes)}, {colMaxStored, humanBytes(r.MaxStoredBytes)}, + {colFree, humanBytes(r.freeBytes())}, } } + +// freeBytes is the limit minus the stored bytes, or zero when the stored bytes +// reach or pass the limit (the API reads the two separately). +func (r volumeUsageResult) freeBytes() int64 { + return max(r.MaxStoredBytes-r.StoredBytes, 0) +} diff --git a/internal/cmd/serverless/volumes_manage.go b/internal/cmd/serverless/volumes_manage.go index fbc3f04..62ee764 100644 --- a/internal/cmd/serverless/volumes_manage.go +++ b/internal/cmd/serverless/volumes_manage.go @@ -33,11 +33,15 @@ var errNothingToUpdateOnVolume = errors.New("nothing to update; pass --descripti var errVolumeUsageMissing = errors.New("the API did not report the organization's stored bytes") // volumeUsageNote says why the Volume sizes 'volumes list' shows do not add up -// to the stored bytes. The usage table prints it on stderr, and the usage help -// holds it as a paragraph, so the rule is written once. +// to Stored, and why an upload that fits in Free can still be refused. The +// usage table prints it on stderr, and the usage help holds it, so each rule is +// written once. const volumeUsageNote = `A file counts once however many Volumes, apps or environments use it, so adding up the sizes 'volumes list' shows can give more than Stored. That list -also covers one environment, and Stored covers all of them.` +also covers one environment, and Stored covers all of them. + +An upload can be refused even when it fits in Free: content that upload +sessions hold, open or not yet cleaned up, counts against the limit too.` // errVolumesNotEnabled makes 'volumes settings' and 'volumes usage' exit // non-zero, after printing what they can, for an organization without Shared @@ -513,13 +517,11 @@ func newVolumesUsageCmd(logger *log.Logger) *cobra.Command { Use: "usage", Short: "Show the organization's Shared Volume storage against its limit", Long: `Show the bytes the organization's Volumes store (Stored), against its -stored-byte limit (Max stored). +stored-byte limit (Max stored). The table adds what is left (Free); JSON and +YAML carry the exact bytes instead. ` + volumeUsageNote + ` -An upload can be refused before Stored reaches the limit: content that upload -sessions hold, open or not yet cleaned up, counts against it too. - Like 'volumes settings', it exits non-zero when Shared Volumes are not enabled for the organization, after printing the usage when the API reports it.`, Example: ` runware serverless volumes usage diff --git a/internal/cmd/serverless/volumes_manage_test.go b/internal/cmd/serverless/volumes_manage_test.go index 7b675db..8aadab4 100644 --- a/internal/cmd/serverless/volumes_manage_test.go +++ b/internal/cmd/serverless/volumes_manage_test.go @@ -10,6 +10,7 @@ import ( "net/http/httptest" "net/url" "os" + "reflect" "slices" "strings" "sync" @@ -1106,6 +1107,7 @@ func TestVolumesUsageShowsStoredBytesAgainstTheLimit(t *testing.T) { } requireRow(t, run.stdout, colStored, "12.0 GiB") requireRow(t, run.stdout, colMaxStored, "1.0 TiB") + requireRow(t, run.stdout, colFree, "1012.0 GiB") requireOutput(t, run.stderr, volumeUsageNote) if strings.Contains(run.stdout, colAvailable) { t.Fatalf("usage shows access, which belongs to settings:\n%s", run.stdout) @@ -1178,6 +1180,52 @@ func TestVolumesUsageYAMLKeepsBytes(t *testing.T) { } } +// volumeFreeCase is one usage for TestVolumesUsageTableShowsTheHeadroom. +type volumeFreeCase struct { + name string + usage volumeUsageResult + // stored, maxStored and free are the three table values. + stored, maxStored, free string +} + +// Near the limit the rounded Stored and Max stored can look equal, so the Free +// row has to show the headroom; past the limit it shows none. +func TestVolumesUsageTableShowsTheHeadroom(t *testing.T) { + for _, tc := range []volumeFreeCase{ + { + name: "40 MiB left of 500 GiB", + usage: volumeUsageResult{ + StoredBytes: 500<<30 - 40<<20, + MaxStoredBytes: 500 << 30, + }, + stored: "500.0 GiB", + maxStored: "500.0 GiB", + free: "40.0 MiB", + }, + { + name: "past the limit", + usage: volumeUsageResult{ + StoredBytes: 2 << 40, + MaxStoredBytes: 1 << 40, + }, + stored: "2.0 TiB", + maxStored: "1.0 TiB", + free: "0 B", + }, + } { + t.Run(tc.name, func(t *testing.T) { + want := [][]any{ + {colStored, tc.stored}, + {colMaxStored, tc.maxStored}, + {colFree, tc.free}, + } + if got := tc.usage.Rows(); !reflect.DeepEqual(got, want) { + t.Fatalf("rows = %v, want %v", got, want) + } + }) + } +} + func TestVolumesUsageJSONKeepsBytes(t *testing.T) { api := newVolumeAPI(t, map[string][]stubResponse{ "GET " + testVolumeSettings: ok(testSettingsEnabled), From 56a7c90eaaf7125fa8fdc37873666db0d66cf894 Mon Sep 17 00:00:00 2001 From: Emilio Del Tessandoro Date: Tue, 1 Dec 2026 13:27:15 +0100 Subject: [PATCH 9/9] test(serverless): pin the volumes usage note in its help The usage help must hold volumeUsageNote, so a help rewrite that stops using the constant fails instead of letting the two texts drift. --- internal/cmd/serverless/volumes_manage_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/cmd/serverless/volumes_manage_test.go b/internal/cmd/serverless/volumes_manage_test.go index 8aadab4..042ef2d 100644 --- a/internal/cmd/serverless/volumes_manage_test.go +++ b/internal/cmd/serverless/volumes_manage_test.go @@ -1268,6 +1268,14 @@ func TestVolumesUsageFailsWhenTheAPISendsNoUsage(t *testing.T) { } } +// The usage help must hold the note the table prints, so the two cannot drift. +func TestVolumesUsageHelpHoldsTheNote(t *testing.T) { + cmd := newVolumesUsageCmd(log.New(io.Discard)) + if !strings.Contains(cmd.Long, volumeUsageNote) { + t.Fatalf("usage help lacks volumeUsageNote:\n%s", cmd.Long) + } +} + func TestVolumesUsageTakesNoEnvironment(t *testing.T) { withDefaultEnvironment(t, testEnvironment) cmd := newVolumesUsageCmd(log.New(io.Discard))