From fefacff9548c13e9f7a22b74b5e6949907d8773b Mon Sep 17 00:00:00 2001 From: Alex Rhee Date: Mon, 9 Nov 2026 11:31:00 -0500 Subject: [PATCH 1/4] docs: add GKE sandbox retention rollout --- .../examples/gke-loop-runtime/README.md | 47 +++++++++++++++++++ .../sandbox-service-retention.yaml | 4 ++ 2 files changed, 51 insertions(+) create mode 100644 braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml diff --git a/braintrust/examples/gke-loop-runtime/README.md b/braintrust/examples/gke-loop-runtime/README.md index b41364f..f7c7951 100644 --- a/braintrust/examples/gke-loop-runtime/README.md +++ b/braintrust/examples/gke-loop-runtime/README.md @@ -56,6 +56,53 @@ Workers run at a fixed count. One `c4-standard-8-lssd` worker holds about seven 1 vCPU / 2 GiB sandboxes; beyond that, new sandboxes fail with `CapacityExhausted`. Raise `replicas` in `sandbox-service.yaml` to add workers. +## Filesystem retention + +The worker package and image pinned above use node-local storage. They do not +enable durable filesystem checkpoints. To enable retention, use a published +Sandbox Service chart and image whose release supports filesystem retention, +alongside a compatible Loop Runtime image. Updating only the image or passing +retention values to the older chart does not enable this feature. + +Apply the GCP Terraform module's checkpoint-storage update first. Its +`gke_isolated_workers.checkpoint_store` output identifies a dedicated private GCS +bucket. Copy that URI into `sandbox-service-retention.yaml`. Worker nodes receive +object access to that bucket through their node identity; the primary runtime and +isolated services pool do not need checkpoint access. + +Set `SANDBOX_SERVICE_CHART_URL` and `SANDBOX_SERVICE_IMAGE` to the compatible +published artifacts, then apply the overlay to the worker release: + +```sh +: "${SANDBOX_SERVICE_CHART_URL:?set a retention-capable published worker chart URL}" +: "${SANDBOX_SERVICE_IMAGE:?set a compatible published worker image}" +helm --kube-context upgrade --install sandbox-service \ + "$SANDBOX_SERVICE_CHART_URL" --namespace braintrust-sandbox \ + --values braintrust/examples/gke-loop-runtime/sandbox-service.yaml \ + --values braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml \ + --set-string image="$SANDBOX_SERVICE_IMAGE" --wait +``` + +Existing releases using `--reuse-values` must explicitly set both retention +values and the compatible image; do not rely on new chart defaults to replace +retained settings. The worker controller continues to own replica changes and +draining. Keep its eviction protections and provision capacity for a replacement +worker during upgrades. + +The workers still use local SSDs formatted as XFS for their working disks. +Checkpoints preserve files at completed idle sleep or preserving drain; they do +not preserve running processes or edits since the last completed checkpoint. +Before relying on recovery, verify that a file survives sleep, wake, and worker +node replacement in the target deployment. Allow disk headroom for retained +local checkpoints as well as active sandboxes. + +Keep the checkpoint bucket and URI stable while retained sandboxes exist. +Coordinate any return to workers without retention support before disabling it. +Removing the worker infrastructure retains the bucket; save its URI and retain +the encryption key, and import the original storage before re-enabling workers +with existing checkpoints. See the Terraform module's +[storage lifecycle](https://github.com/braintrustdata/terraform-google-braintrust-data-plane/blob/main/ISOLATED_WORKERS.md#storage-and-lifecycle). + Loop Runtime defaults to one pod. Rolling updates use `maxSurge: 1` and `maxUnavailable: 0`, giving a 1 → 2 → 1 rollout. Increase `loopRuntime.replicas` for more capacity or pod redundancy. diff --git a/braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml b/braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml new file mode 100644 index 0000000..c743367 --- /dev/null +++ b/braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml @@ -0,0 +1,4 @@ +# Overlay for a Sandbox Service release that supports filesystem retention. +# Apply the GCP infrastructure update first, then use its checkpoint_store output. +filesystemRetention: true +checkpointStore: "" From 36061b5ecb092f16e44b6e6fc2218b3fae181fa1 Mon Sep 17 00:00:00 2001 From: Alex Rhee Date: Wed, 18 Nov 2026 22:02:21 -0800 Subject: [PATCH 2/4] Update GKE sandbox worker sizing and release pins --- .../examples/gke-loop-runtime/README.md | 42 +++--- .../gke-loop-runtime/sandbox-service.yaml | 4 +- .../templates/loop-runtime-configmap.yaml | 2 + .../tests/loop-runtime-capacity_test.yaml | 139 ++++++++++++++++++ 4 files changed, 168 insertions(+), 19 deletions(-) create mode 100644 braintrust/tests/loop-runtime-capacity_test.yaml diff --git a/braintrust/examples/gke-loop-runtime/README.md b/braintrust/examples/gke-loop-runtime/README.md index f7c7951..1a4137d 100644 --- a/braintrust/examples/gke-loop-runtime/README.md +++ b/braintrust/examples/gke-loop-runtime/README.md @@ -39,7 +39,7 @@ uses the same URL. To override it for Loop only, set `BRAINTRUST_APP_URL` in ```sh helm --kube-context upgrade --install sandbox-service \ - https://braintrust-cf-us-east-1.s3.amazonaws.com/sandbox-service/1f4b6826c61064575b3db956b67625133257bd8a6e49e4ea86cdb55012dd53a7/sandbox-service-0.1.0.tgz \ + https://braintrust-cf-us-east-1.s3.amazonaws.com/sandbox-service/062fbf5e1090e1f624eda6d6f9dfe7af05921e3d90a6405d330feb7866775ad2/sandbox-service-0.1.0.tgz \ --namespace braintrust-sandbox --values braintrust/examples/gke-loop-runtime/sandbox-service.yaml --wait ``` @@ -52,17 +52,18 @@ uses the same URL. To override it for Loop only, set `BRAINTRUST_APP_URL` in --values --values braintrust/examples/gke-loop-runtime/values.yaml --wait ``` -Workers run at a fixed count. One `c4-standard-8-lssd` worker holds about seven -1 vCPU / 2 GiB sandboxes; beyond that, new sandboxes fail with -`CapacityExhausted`. Raise `replicas` in `sandbox-service.yaml` to add workers. +Worker `replicas` sets the minimum count. The worker controller scales from +reported sandbox demand and usable worker capacity, bounded by +`controller.maxReplicas` and the Terraform node-pool maximum. Keep room for an +extra worker during upgrades; insufficient capacity can still return +`CapacityExhausted` while new workers are provisioning or when limits are reached. ## Filesystem retention -The worker package and image pinned above use node-local storage. They do not -enable durable filesystem checkpoints. To enable retention, use a published -Sandbox Service chart and image whose release supports filesystem retention, -alongside a compatible Loop Runtime image. Updating only the image or passing -retention values to the older chart does not enable this feature. +The pinned worker chart and image support filesystem retention, which remains +off unless the retention overlay is applied. Keep the worker chart, worker image +and Loop Runtime image compatible; updating only the image can omit required +controller settings from an older chart. Apply the GCP Terraform module's checkpoint-storage update first. Its `gke_isolated_workers.checkpoint_store` output identifies a dedicated private GCS @@ -70,17 +71,14 @@ bucket. Copy that URI into `sandbox-service-retention.yaml`. Worker nodes receiv object access to that bucket through their node identity; the primary runtime and isolated services pool do not need checkpoint access. -Set `SANDBOX_SERVICE_CHART_URL` and `SANDBOX_SERVICE_IMAGE` to the compatible -published artifacts, then apply the overlay to the worker release: +Apply the overlay using the same published worker chart and image as above: ```sh -: "${SANDBOX_SERVICE_CHART_URL:?set a retention-capable published worker chart URL}" -: "${SANDBOX_SERVICE_IMAGE:?set a compatible published worker image}" helm --kube-context upgrade --install sandbox-service \ - "$SANDBOX_SERVICE_CHART_URL" --namespace braintrust-sandbox \ + https://braintrust-cf-us-east-1.s3.amazonaws.com/sandbox-service/062fbf5e1090e1f624eda6d6f9dfe7af05921e3d90a6405d330feb7866775ad2/sandbox-service-0.1.0.tgz \ + --namespace braintrust-sandbox \ --values braintrust/examples/gke-loop-runtime/sandbox-service.yaml \ - --values braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml \ - --set-string image="$SANDBOX_SERVICE_IMAGE" --wait + --values braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml --wait ``` Existing releases using `--reuse-values` must explicitly set both retention @@ -89,6 +87,12 @@ retained settings. The worker controller continues to own replica changes and draining. Keep its eviction protections and provision capacity for a replacement worker during upgrades. +Upgrade replacements have a 15-minute drain deadline by default. On expiry the +controller can retire the old worker, losing active edits or local-only +checkpoints. Set `SANDBOX_SERVICE_WORKER_DRAIN_TIMEOUT_SECONDS` in the worker +chart's `controller.env` to change the deadline; `0` disables forced retirement. +This deadline applies to old-revision replacements, not ordinary scale-down. + The workers still use local SSDs formatted as XFS for their working disks. Checkpoints preserve files at completed idle sleep or preserving drain; they do not preserve running processes or edits since the last completed checkpoint. @@ -119,7 +123,11 @@ The application must expose the gauge `loop_runtime_claimed_conversation_utiliza An image without that endpoint or gauge cannot drive metric-based scaling; there is no image-version gate. The HPA owns replicas while enabled; disabling it restores `loopRuntime.replicas`. Enabling it on an existing Deployment can initially reset the count to one. -This scales runtime pods only; provision worker replicas separately for the expected sandbox capacity. +The enabled runtime HPA's utilization target also sets sandbox capacity headroom. +The sandbox runtime accepts targets of at least 1%, so an HPA target below 1% +uses 1% for workers while preserving the HPA target. With runtime autoscaling +disabled, worker capacity keeps its 50% target. Worker and node-pool maximums +still bound sandbox capacity independently of the runtime HPA. Sandbox administration is disabled by default. Set `loopRuntime.enableSandboxAdmin: true` to allow authorized sysadmins to inspect and terminate sandboxes. diff --git a/braintrust/examples/gke-loop-runtime/sandbox-service.yaml b/braintrust/examples/gke-loop-runtime/sandbox-service.yaml index 3688e5a..e0c5e21 100644 --- a/braintrust/examples/gke-loop-runtime/sandbox-service.yaml +++ b/braintrust/examples/gke-loop-runtime/sandbox-service.yaml @@ -1,8 +1,8 @@ # Values for the Sandbox Service worker chart, installed in the isolated worker cluster. # Every <...> value comes from the GCP Terraform output gke_isolated_workers. hostname: "" -image: public.ecr.aws/braintrust/sandbox-service:v2.21.0 -# Fixed worker capacity. The worker node pool autoscales, so raising this is a values change. +image: public.ecr.aws/braintrust/sandbox-service:v2.24.0 +# Worker floor. The controller scales from sandbox demand within the node-pool limits. replicas: 1 gitResources: true nodePrep: diff --git a/braintrust/templates/loop-runtime-configmap.yaml b/braintrust/templates/loop-runtime-configmap.yaml index 4ad7787..1d1cab7 100644 --- a/braintrust/templates/loop-runtime-configmap.yaml +++ b/braintrust/templates/loop-runtime-configmap.yaml @@ -2,6 +2,7 @@ {{- if include "braintrust.loopRuntime.enabled" . -}} {{- $bucket := printf "gs://%s" .Values.objectStorage.google.brainstoreBucket -}} {{- $sandbox := .Values.loopRuntime.sandbox -}} +{{- $autoscaling := include "braintrust.loopRuntime.autoscaling" . | fromYaml -}} apiVersion: v1 kind: ConfigMap metadata: @@ -39,6 +40,7 @@ data: BRAINSTORE_OBJECT_STORE_CACHE_FILE_SIZE: 5Gi BRAINSTORE_OBJECT_STORE_CACHE_MEMORY_LIMIT: 256Mi LOOP_RUNTIME_MAX_CLAIMED_CONVERSATIONS: "2" + LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT: {{ maxf 1 (float64 ($autoscaling.targetConversationUtilization | default "50")) | quote }} BRAINSTORE_CONTROL_PLANE_TELEMETRY: {{ list .Values.global.controlPlaneTelemetry "metrics" "traces" | compact | join "," | quote }} NO_COLOR: "1" EXO_SANDBOX_SERVICE_DNS_URL: {{ $sandbox.dnsUrl | quote }} diff --git a/braintrust/tests/loop-runtime-capacity_test.yaml b/braintrust/tests/loop-runtime-capacity_test.yaml new file mode 100644 index 0000000..e93c253 --- /dev/null +++ b/braintrust/tests/loop-runtime-capacity_test.yaml @@ -0,0 +1,139 @@ +suite: Loop Runtime sandbox capacity target +templates: + - loop-runtime-configmap.yaml + - loop-runtime-hpa.yaml +capabilities: + apiVersions: + - autoscaling.gke.io/v1beta1 +tests: + - it: omits capacity configuration when Loop is disabled + template: loop-runtime-configmap.yaml + values: + - __fixtures__/base-values.yaml + asserts: + - hasDocuments: + count: 0 + + - it: keeps the worker target at fifty percent without the runtime HPA + values: &values + - __fixtures__/base-values.yaml + - __fixtures__/loop-runtime-values.yaml + asserts: + - equal: &defaultTarget + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "50" + template: loop-runtime-configmap.yaml + - hasDocuments: + count: 0 + template: loop-runtime-hpa.yaml + + - it: shares a custom enabled HPA target with sandbox workers + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "70" + asserts: + - equal: + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "70" + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "70" + template: loop-runtime-hpa.yaml + + - it: preserves fractional utilization targets supported by the runtime + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: 35.5 + asserts: + - equal: + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "35.5" + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "35.5" + template: loop-runtime-hpa.yaml + + - it: preserves sub-percent HPA targets while respecting the runtime minimum + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "0.5" + asserts: + - equal: + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "1" + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "0.5" + template: loop-runtime-hpa.yaml + + - it: tolerates retained values without an autoscaling map + template: loop-runtime-configmap.yaml + values: *values + set: + loopRuntime.autoscaling: null + asserts: + - equal: *defaultTarget + + - it: fills the capacity target for partial reused autoscaling values + values: + - __fixtures__/base-values.yaml + - __fixtures__/loop-runtime-values.yaml + - __fixtures__/reuse-loop-runtime-autoscaling-values.yaml + set: + loopRuntime.autoscaling.enabled: true + asserts: + - equal: *defaultTarget + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "50" + template: loop-runtime-hpa.yaml + + - it: defaults a null target when the HPA is enabled + template: loop-runtime-configmap.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: null + asserts: + - equal: *defaultTarget + + - it: continues ignoring unused HPA targets when it is disabled + template: loop-runtime-configmap.yaml + values: *values + set: + loopRuntime.autoscaling.targetConversationUtilization: 0 + asserts: + - equal: *defaultTarget + + - it: rejects a zero enabled HPA target before starting the runtime + template: loop-runtime-hpa.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: 0 + asserts: &invalidTarget + - failedTemplate: + errorMessage: loopRuntime.autoscaling.targetConversationUtilization must be greater than 0 and at most 100 + + - it: rejects an empty enabled HPA target + template: loop-runtime-hpa.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "" + asserts: *invalidTarget + + - it: rejects an enabled HPA target above one hundred + template: loop-runtime-hpa.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "101" + asserts: *invalidTarget From 80a523cbc3b34c06044a44858da00f6051758960 Mon Sep 17 00:00:00 2001 From: Alex Rhee Date: Thu, 19 Nov 2026 11:46:45 -0800 Subject: [PATCH 3/4] Pin the sandbox worker chart in Helm release values --- braintrust/examples/gke-loop-runtime/README.md | 3 +++ braintrust/values.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/braintrust/examples/gke-loop-runtime/README.md b/braintrust/examples/gke-loop-runtime/README.md index 1a4137d..aa3fc1c 100644 --- a/braintrust/examples/gke-loop-runtime/README.md +++ b/braintrust/examples/gke-loop-runtime/README.md @@ -64,6 +64,9 @@ The pinned worker chart and image support filesystem retention, which remains off unless the retention overlay is applied. Keep the worker chart, worker image and Loop Runtime image compatible; updating only the image can omit required controller settings from an older chart. +The worker package URL is recorded in `loopRuntime.sandboxServiceChart` in the +Braintrust chart's release values. The Terraform installer reads that pin from +the selected chart release and installs it in the isolated worker cluster. Apply the GCP Terraform module's checkpoint-storage update first. Its `gke_isolated_workers.checkpoint_store` output identifies a dedicated private GCS diff --git a/braintrust/values.yaml b/braintrust/values.yaml index fb51071..9d55d3d 100644 --- a/braintrust/values.yaml +++ b/braintrust/values.yaml @@ -309,6 +309,8 @@ loopRuntime: repository: public.ecr.aws/braintrust/loop-runtime tag: v2.24.0 pullPolicy: IfNotPresent + # Separate worker chart, pinned with this release for the Terraform installer. + sandboxServiceChart: "https://braintrust-cf-us-east-1.s3.amazonaws.com/sandbox-service/062fbf5e1090e1f624eda6d6f9dfe7af05921e3d90a6405d330feb7866775ad2/sandbox-service-0.1.0.tgz" # Requires the same GKE custom-metrics prerequisites as api.autoscaling. # Without the application metric, the HPA cannot perform metric-driven scaling. autoscaling: From 92f3d4323c3171db55b1d4c9bf0d4a12a0998b06 Mon Sep 17 00:00:00 2001 From: Alex Rhee Date: Thu, 19 Nov 2026 12:10:30 -0800 Subject: [PATCH 4/4] Consolidate sandbox tests and stabilize migration fixtures --- .../examples/gke-loop-runtime/README.md | 75 ++++------ .../tests/loop-runtime-autoscaling_test.yaml | 67 ++++++++- .../tests/loop-runtime-capacity_test.yaml | 139 ------------------ .../tests/loop-runtime-configmap_test.yaml | 3 + braintrust/tests/migrations_test.yaml | 2 + 5 files changed, 100 insertions(+), 186 deletions(-) delete mode 100644 braintrust/tests/loop-runtime-capacity_test.yaml diff --git a/braintrust/examples/gke-loop-runtime/README.md b/braintrust/examples/gke-loop-runtime/README.md index aa3fc1c..5a509c2 100644 --- a/braintrust/examples/gke-loop-runtime/README.md +++ b/braintrust/examples/gke-loop-runtime/README.md @@ -52,27 +52,20 @@ uses the same URL. To override it for Loop only, set `BRAINTRUST_APP_URL` in --values --values braintrust/examples/gke-loop-runtime/values.yaml --wait ``` -Worker `replicas` sets the minimum count. The worker controller scales from -reported sandbox demand and usable worker capacity, bounded by -`controller.maxReplicas` and the Terraform node-pool maximum. Keep room for an -extra worker during upgrades; insufficient capacity can still return -`CapacityExhausted` while new workers are provisioning or when limits are reached. +Worker `replicas` is a floor; the controller scales from demand and usable capacity +within `controller.maxReplicas` and the Terraform node-pool maximum. Reserve an +extra worker for upgrades; requests can return `CapacityExhausted` while scaling +or at those limits. ## Filesystem retention -The pinned worker chart and image support filesystem retention, which remains -off unless the retention overlay is applied. Keep the worker chart, worker image -and Loop Runtime image compatible; updating only the image can omit required -controller settings from an older chart. -The worker package URL is recorded in `loopRuntime.sandboxServiceChart` in the -Braintrust chart's release values. The Terraform installer reads that pin from -the selected chart release and installs it in the isolated worker cluster. +Retention is off unless the overlay is applied. Keep the worker chart, worker image +and Loop Runtime image compatible. Terraform selects the worker package from +`loopRuntime.sandboxServiceChart` in the chosen Braintrust Helm release. -Apply the GCP Terraform module's checkpoint-storage update first. Its -`gke_isolated_workers.checkpoint_store` output identifies a dedicated private GCS -bucket. Copy that URI into `sandbox-service-retention.yaml`. Worker nodes receive -object access to that bucket through their node identity; the primary runtime and -isolated services pool do not need checkpoint access. +Apply the GCP checkpoint-storage update first, then copy +`gke_isolated_workers.checkpoint_store` into `sandbox-service-retention.yaml`. +Only worker nodes receive checkpoint-bucket access through their node identity. Apply the overlay using the same published worker chart and image as above: @@ -84,30 +77,22 @@ helm --kube-context upgrade --install sandbox-service \ --values braintrust/examples/gke-loop-runtime/sandbox-service-retention.yaml --wait ``` -Existing releases using `--reuse-values` must explicitly set both retention -values and the compatible image; do not rely on new chart defaults to replace -retained settings. The worker controller continues to own replica changes and -draining. Keep its eviction protections and provision capacity for a replacement -worker during upgrades. - -Upgrade replacements have a 15-minute drain deadline by default. On expiry the -controller can retire the old worker, losing active edits or local-only -checkpoints. Set `SANDBOX_SERVICE_WORKER_DRAIN_TIMEOUT_SECONDS` in the worker -chart's `controller.env` to change the deadline; `0` disables forced retirement. -This deadline applies to old-revision replacements, not ordinary scale-down. - -The workers still use local SSDs formatted as XFS for their working disks. -Checkpoints preserve files at completed idle sleep or preserving drain; they do -not preserve running processes or edits since the last completed checkpoint. -Before relying on recovery, verify that a file survives sleep, wake, and worker -node replacement in the target deployment. Allow disk headroom for retained -local checkpoints as well as active sandboxes. - -Keep the checkpoint bucket and URI stable while retained sandboxes exist. -Coordinate any return to workers without retention support before disabling it. -Removing the worker infrastructure retains the bucket; save its URI and retain -the encryption key, and import the original storage before re-enabling workers -with existing checkpoints. See the Terraform module's +With `--reuse-values`, explicitly set both retention values and a compatible image. +The controller owns scaling and draining; retain its eviction protections. + +Upgrade replacements default to a 15-minute drain deadline; expiry can lose active +edits or local-only checkpoints. Change `SANDBOX_SERVICE_WORKER_DRAIN_TIMEOUT_SECONDS` +in `controller.env`, or use `0` to wait indefinitely. Ordinary scale-down has no +such deadline. + +Workers still use local SSD/XFS. Checkpoints preserve files at completed idle sleep +or preserving drain, excluding running processes and later edits. Allow local disk +headroom for checkpoints and active sandboxes, and verify file recovery across +sleep, wake, and worker replacement before relying on it. + +Keep the bucket, URI and encryption key stable while retained sandboxes exist. +Coordinate rollback before disabling retention. Infrastructure removal retains +the bucket; import the original storage before re-enabling workers. See the [storage lifecycle](https://github.com/braintrustdata/terraform-google-braintrust-data-plane/blob/main/ISOLATED_WORKERS.md#storage-and-lifecycle). Loop Runtime defaults to one pod. Rolling updates use `maxSurge: 1` and @@ -126,11 +111,9 @@ The application must expose the gauge `loop_runtime_claimed_conversation_utiliza An image without that endpoint or gauge cannot drive metric-based scaling; there is no image-version gate. The HPA owns replicas while enabled; disabling it restores `loopRuntime.replicas`. Enabling it on an existing Deployment can initially reset the count to one. -The enabled runtime HPA's utilization target also sets sandbox capacity headroom. -The sandbox runtime accepts targets of at least 1%, so an HPA target below 1% -uses 1% for workers while preserving the HPA target. With runtime autoscaling -disabled, worker capacity keeps its 50% target. Worker and node-pool maximums -still bound sandbox capacity independently of the runtime HPA. +The HPA target also sets sandbox capacity headroom, with a 1% sandbox minimum. +HPA targets below 1% stay unchanged; disabled autoscaling keeps the sandbox target +at 50%. Worker and node-pool maximums still bound sandbox capacity. Sandbox administration is disabled by default. Set `loopRuntime.enableSandboxAdmin: true` to allow authorized sysadmins to inspect and terminate sandboxes. diff --git a/braintrust/tests/loop-runtime-autoscaling_test.yaml b/braintrust/tests/loop-runtime-autoscaling_test.yaml index 41ee6c3..0cc9b50 100644 --- a/braintrust/tests/loop-runtime-autoscaling_test.yaml +++ b/braintrust/tests/loop-runtime-autoscaling_test.yaml @@ -13,6 +13,8 @@ tests: values: &values - __fixtures__/base-values.yaml - __fixtures__/loop-runtime-values.yaml + set: + loopRuntime.autoscaling.targetConversationUtilization: 0 asserts: - hasDocuments: count: 0 @@ -24,6 +26,10 @@ tests: path: spec.replicas value: 1 template: loop-runtime-deployment.yaml + - equal: &capacityTarget + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "50" + template: loop-runtime-configmap.yaml - it: should reject a zero autoscaling minimum template: loop-runtime-hpa.yaml @@ -70,9 +76,27 @@ tests: loopRuntime.autoscaling.enabled: true loopRuntime.autoscaling.targetConversationUtilization: "101" asserts: - - failedTemplate: + - failedTemplate: &invalidTarget errorMessage: loopRuntime.autoscaling.targetConversationUtilization must be greater than 0 and at most 100 + - it: should reject a zero conversation utilization target + template: loop-runtime-hpa.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: 0 + asserts: + - failedTemplate: *invalidTarget + + - it: should reject an empty conversation utilization target + template: loop-runtime-hpa.yaml + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "" + asserts: + - failedTemplate: *invalidTarget + - it: should reject a relative metrics endpoint template: loop-runtime-hpa.yaml values: *values @@ -155,6 +179,8 @@ tests: set: loopRuntime.autoscaling.enabled: true asserts: &autoscalingDefaults + - equal: *capacityTarget + template: loop-runtime-configmap.yaml - equal: path: spec.minReplicas value: 1 @@ -198,6 +224,10 @@ tests: metricsPath: /capacity targetConversationUtilization: "75" asserts: + - equal: + <<: *capacityTarget + value: "75" + template: loop-runtime-configmap.yaml - equal: path: spec.minReplicas value: 2 @@ -226,6 +256,9 @@ tests: loopRuntime.enabled: false loopRuntime.autoscaling.enabled: true asserts: + - hasDocuments: + count: 0 + template: loop-runtime-configmap.yaml - hasDocuments: count: 0 template: loop-runtime-hpa.yaml @@ -239,6 +272,8 @@ tests: loopRuntime.replicas: 3 loopRuntime.autoscaling: null asserts: + - equal: *capacityTarget + template: loop-runtime-configmap.yaml - equal: path: spec.replicas value: 3 @@ -246,3 +281,33 @@ tests: - hasDocuments: count: 0 template: loop-runtime-hpa.yaml + + - it: should share a fractional HPA target with sandbox capacity + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: 35.5 + asserts: + - equal: + <<: *capacityTarget + value: "35.5" + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "35.5" + template: loop-runtime-hpa.yaml + + - it: should preserve sub-percent HPA targets while respecting the sandbox minimum + values: *values + set: + loopRuntime.autoscaling.enabled: true + loopRuntime.autoscaling.targetConversationUtilization: "0.5" + asserts: + - equal: + <<: *capacityTarget + value: "1" + template: loop-runtime-configmap.yaml + - equal: + path: spec.metrics[0].pods.target.averageValue + value: "0.5" + template: loop-runtime-hpa.yaml diff --git a/braintrust/tests/loop-runtime-capacity_test.yaml b/braintrust/tests/loop-runtime-capacity_test.yaml deleted file mode 100644 index e93c253..0000000 --- a/braintrust/tests/loop-runtime-capacity_test.yaml +++ /dev/null @@ -1,139 +0,0 @@ -suite: Loop Runtime sandbox capacity target -templates: - - loop-runtime-configmap.yaml - - loop-runtime-hpa.yaml -capabilities: - apiVersions: - - autoscaling.gke.io/v1beta1 -tests: - - it: omits capacity configuration when Loop is disabled - template: loop-runtime-configmap.yaml - values: - - __fixtures__/base-values.yaml - asserts: - - hasDocuments: - count: 0 - - - it: keeps the worker target at fifty percent without the runtime HPA - values: &values - - __fixtures__/base-values.yaml - - __fixtures__/loop-runtime-values.yaml - asserts: - - equal: &defaultTarget - path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT - value: "50" - template: loop-runtime-configmap.yaml - - hasDocuments: - count: 0 - template: loop-runtime-hpa.yaml - - - it: shares a custom enabled HPA target with sandbox workers - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: "70" - asserts: - - equal: - path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT - value: "70" - template: loop-runtime-configmap.yaml - - equal: - path: spec.metrics[0].pods.target.averageValue - value: "70" - template: loop-runtime-hpa.yaml - - - it: preserves fractional utilization targets supported by the runtime - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: 35.5 - asserts: - - equal: - path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT - value: "35.5" - template: loop-runtime-configmap.yaml - - equal: - path: spec.metrics[0].pods.target.averageValue - value: "35.5" - template: loop-runtime-hpa.yaml - - - it: preserves sub-percent HPA targets while respecting the runtime minimum - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: "0.5" - asserts: - - equal: - path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT - value: "1" - template: loop-runtime-configmap.yaml - - equal: - path: spec.metrics[0].pods.target.averageValue - value: "0.5" - template: loop-runtime-hpa.yaml - - - it: tolerates retained values without an autoscaling map - template: loop-runtime-configmap.yaml - values: *values - set: - loopRuntime.autoscaling: null - asserts: - - equal: *defaultTarget - - - it: fills the capacity target for partial reused autoscaling values - values: - - __fixtures__/base-values.yaml - - __fixtures__/loop-runtime-values.yaml - - __fixtures__/reuse-loop-runtime-autoscaling-values.yaml - set: - loopRuntime.autoscaling.enabled: true - asserts: - - equal: *defaultTarget - template: loop-runtime-configmap.yaml - - equal: - path: spec.metrics[0].pods.target.averageValue - value: "50" - template: loop-runtime-hpa.yaml - - - it: defaults a null target when the HPA is enabled - template: loop-runtime-configmap.yaml - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: null - asserts: - - equal: *defaultTarget - - - it: continues ignoring unused HPA targets when it is disabled - template: loop-runtime-configmap.yaml - values: *values - set: - loopRuntime.autoscaling.targetConversationUtilization: 0 - asserts: - - equal: *defaultTarget - - - it: rejects a zero enabled HPA target before starting the runtime - template: loop-runtime-hpa.yaml - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: 0 - asserts: &invalidTarget - - failedTemplate: - errorMessage: loopRuntime.autoscaling.targetConversationUtilization must be greater than 0 and at most 100 - - - it: rejects an empty enabled HPA target - template: loop-runtime-hpa.yaml - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: "" - asserts: *invalidTarget - - - it: rejects an enabled HPA target above one hundred - template: loop-runtime-hpa.yaml - values: *values - set: - loopRuntime.autoscaling.enabled: true - loopRuntime.autoscaling.targetConversationUtilization: "101" - asserts: *invalidTarget diff --git a/braintrust/tests/loop-runtime-configmap_test.yaml b/braintrust/tests/loop-runtime-configmap_test.yaml index 019b250..3b0154c 100644 --- a/braintrust/tests/loop-runtime-configmap_test.yaml +++ b/braintrust/tests/loop-runtime-configmap_test.yaml @@ -75,6 +75,9 @@ tests: - equal: path: data.LOOP_RUNTIME_MAX_CLAIMED_CONVERSATIONS value: "2" + - equal: + path: data.LOOP_RUNTIME_SANDBOX_CAPACITY_TARGET_UTILIZATION_PERCENT + value: "50" - isNull: path: data.BRAINSTORE_LOCKS_URI diff --git a/braintrust/tests/migrations_test.yaml b/braintrust/tests/migrations_test.yaml index 13e4dbe..68c1a35 100644 --- a/braintrust/tests/migrations_test.yaml +++ b/braintrust/tests/migrations_test.yaml @@ -28,6 +28,7 @@ tests: set: api.image.repository: registry.example/custom-api api.image.tag: v2.15.0 + brainstore.image.tag: v2.23.0 asserts: - isKind: of: Job @@ -631,6 +632,7 @@ tests: - __fixtures__/loop-runtime-values.yaml set: api.image.tag: deadbeef + brainstore.image.tag: v2.23.0 deploymentOrdering.minimumVersion: v2.15.0 deploymentOrdering.migrationImageTag: v2.23.0 asserts: