Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(fleet): default claim bind deadline to 900s (#7039)
r33drichards06619382aefc
diff --git a/libs/fleet/sdk-bindings/README.md b/libs/fleet/sdk-bindings/README.mdindex 23ac169a7d..56ae860968 100644--- a/libs/fleet/sdk-bindings/README.md+++ b/libs/fleet/sdk-bindings/README.md@@ -234,7 +234,7 @@ pool = await client.create_pool(CreatePoolRequest(namespace="default", spec=poolclaim_spec = ClaimSpec(sandbox_template_ref=SandboxTemplateRef(name=pool.metadata.name),warmpool=None,- bind_deadline=None,+ bind_deadline=None, # SDK defaults omitted deadlines to 900 secondslifecycle=None,)claim = await client.create_claim(CreateClaimRequest(pool=pool, spec=claim_spec))diff --git a/libs/fleet/sdk-schema/src/claim.rs b/libs/fleet/sdk-schema/src/claim.rsindex 47fb0c9fdd..e7cc045cfa 100644--- a/libs/fleet/sdk-schema/src/claim.rs+++ b/libs/fleet/sdk-schema/src/claim.rs@@ -6,6 +6,8 @@ use kube::CustomResource;use schemars::JsonSchema;use serde::{Deserialize, Serialize};+pub const DEFAULT_CLAIM_BIND_DEADLINE_SECONDS: u32 = 900;+fn default_warmpool() -> Option<String> {Some("default".into())}@@ -174,7 +176,7 @@ pub struct ClaimSpec {default,schema_with = "integer_schema",range(min = 0),- description = "Seconds the claim stays Pending waiting for a Sandbox to\nbind before it is marked Failed (default 300, set by the\noperator's OSGYM_CLAIM_BIND_DEADLINE). A Pending claim is\nthe autoscaler's demand signal, so the claim is kept\nPending across a cold VM boot + KEDA scale-up rather than\nfailing fast. Raise it for pools with slow cold starts.\n"+ description = "Seconds the claim stays Pending waiting for a Sandbox to\nbind before it is marked Failed (default 900, set by the\noperator's OSGYM_CLAIM_BIND_DEADLINE). A Pending claim is\nthe autoscaler's demand signal, so the claim is kept\nPending across a cold VM boot + KEDA scale-up rather than\nfailing fast. Override it for pools with different cold-start\nrequirements.\n")]#[serde(skip_serializing_if = "Option::is_none")]pub bind_deadline: Option<u32>,diff --git a/libs/fleet/sdk-schema/src/lib.rs b/libs/fleet/sdk-schema/src/lib.rsindex 1d69ff8db0..0183356451 100644--- a/libs/fleet/sdk-schema/src/lib.rs+++ b/libs/fleet/sdk-schema/src/lib.rs@@ -6,8 +6,8 @@ mod sandbox;mod warmpool;pub use claim::{- ClaimLifecycle, ClaimSpec, OSGymSandboxClaim, OSGymSandboxClaimCondition,- OSGymSandboxClaimSandbox, OSGymSandboxClaimStatus,+ ClaimLifecycle, ClaimSpec, DEFAULT_CLAIM_BIND_DEADLINE_SECONDS, OSGymSandboxClaim,+ OSGymSandboxClaimCondition, OSGymSandboxClaimSandbox, OSGymSandboxClaimStatus,};pub use common::{Firmware, ImagePullPolicy, OidcConfig, RuntimeKind, SandboxService, SandboxServiceBuilder,diff --git a/libs/fleet/sdk-schema/tests/claim_crds.rs b/libs/fleet/sdk-schema/tests/claim_crds.rsindex 703967c892..5e7e4f87fd 100644--- a/libs/fleet/sdk-schema/tests/claim_crds.rs+++ b/libs/fleet/sdk-schema/tests/claim_crds.rs@@ -107,6 +107,22 @@ fn warm_pool_raw_crd_matches_the_authoritative_field_contract() {assert_eq!(generated, authoritative);}+#[test]+fn claim_bind_deadline_schema_documents_900_second_default_without_materializing_it() {+ let claim = serde_json::to_value(OSGymSandboxClaim::crd()).unwrap();+ let bind_deadline = claim+ .pointer("/spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/bindDeadline")+ .unwrap();++ assert!(bind_deadline.get("default").is_none());+ assert!(+ bind_deadline["description"]+ .as_str()+ .unwrap()+ .contains("default 900")+ );+}+#[test]fn claim_raw_crd_matches_the_authoritative_field_contract() {let generated = normalize_known_kube_derive_artifacts(diff --git a/libs/fleet/sdk/src/claims.rs b/libs/fleet/sdk/src/claims.rsindex 6b835a8b0b..d584d19ef9 100644--- a/libs/fleet/sdk/src/claims.rs+++ b/libs/fleet/sdk/src/claims.rs@@ -2,7 +2,7 @@ use crate::{Claim, CreateClaimRequest, CyclopsClient, HttpHeader, HttpRequest, HttpResponse, Pool,ResourceMetadata, Sandbox, SdkError, Template, routes,};-use cyclops_sdk_schema::ClaimSpec;+use cyclops_sdk_schema::{ClaimSpec, DEFAULT_CLAIM_BIND_DEADLINE_SECONDS};#[cfg(not(target_arch = "wasm32"))]use futures_timer::Delay;#[cfg(target_arch = "wasm32")]@@ -40,12 +40,15 @@ impl CyclopsClient {// a naming convention. A hand-built ref that names a nonexistent// template makes the bind queue lookup miss forever and the claim// times out with no useful error (the hermes-cua-pool incident).- let spec = request.spec.unwrap_or_else(|| ClaimSpec {+ let mut spec = request.spec.unwrap_or_else(|| ClaimSpec {sandbox_template_ref: pool.spec.sandbox_template_ref.clone(),warmpool: None,- bind_deadline: None,+ bind_deadline: Some(DEFAULT_CLAIM_BIND_DEADLINE_SECONDS),lifecycle: None,});+ if spec.bind_deadline.is_none() {+ spec.bind_deadline = Some(DEFAULT_CLAIM_BIND_DEADLINE_SECONDS);+ }if spec.sandbox_template_ref.name.is_empty() {return Err(SdkError::Configuration {reason: "sandbox template name must not be empty".into(),diff --git a/libs/fleet/sdk/tests/claim_flow.rs b/libs/fleet/sdk/tests/claim_flow.rsindex 16fc21e56e..3937055bdf 100644--- a/libs/fleet/sdk/tests/claim_flow.rs+++ b/libs/fleet/sdk/tests/claim_flow.rs@@ -4,7 +4,7 @@ use cyclops_sdk::{Claim, CreateClaimRequest, CyclopsClient, CyclopsConfiguration, CyclopsCredentials, HttpHeader,HttpResponse, Pool, ResourceMetadata, SdkError, Template,};-use cyclops_sdk_schema::ClaimSpec;+use cyclops_sdk_schema::{ClaimSpec, DEFAULT_CLAIM_BIND_DEADLINE_SECONDS};use std::sync::Arc;use support::ScriptedHttpClient;@@ -45,6 +45,58 @@ async fn creates_pending_demand_immediately_for_a_nonzero_unavailable_pool() {assert_claim_post(&requests[0], &spec);}+#[tokio::test]+async fn create_claim_defaults_missing_bind_deadline_to_900_seconds() {+ let expected = claim("claim-1", claim_spec("example-pool-template"), None);+ let http = Arc::new(ScriptedHttpClient::new([+ Ok(token()),+ Ok(json_response(201, &expected)),+ ]));++ client(Arc::clone(&http), 2, 2)+ .create_claim(CreateClaimRequest {+ pool: pool(1),+ spec: Some({+ let mut spec = claim_spec("example-pool-template");+ spec.bind_deadline = None;+ spec+ }),+ name: None,+ })+ .await+ .unwrap();++ let requests = http.authenticated_requests().await;+ let body: serde_json::Value =+ serde_json::from_slice(requests[0].body.as_deref().unwrap()).unwrap();+ assert_eq!(body["spec"]["bindDeadline"], 900);+}++#[tokio::test]+async fn create_claim_preserves_explicit_bind_deadline() {+ let mut spec = claim_spec("example-pool-template");+ spec.bind_deadline = Some(123);+ let expected = claim("claim-1", spec.clone(), None);+ let http = Arc::new(ScriptedHttpClient::new([+ Ok(token()),+ Ok(json_response(201, &expected)),+ ]));++ client(Arc::clone(&http), 2, 2)+ .create_claim(CreateClaimRequest {+ pool: pool(1),+ spec: Some(spec),+ name: None,+ })+ .await+ .unwrap();++ let requests = http.authenticated_requests().await;+ let body: serde_json::Value =+ serde_json::from_slice(requests[0].body.as_deref().unwrap()).unwrap();+ assert_eq!(body["spec"]["bindDeadline"], 123);+}+#[tokio::test]async fn zero_and_nonzero_pools_post_a_single_claim_create() {for replicas in [0, 1] {@@ -471,9 +523,13 @@ fn assert_claim_post(request: &cyclops_sdk::HttpRequest, spec: &ClaimSpec) {assert_eq!(body.api_version, "osgym.cua.ai/v1alpha1");assert_eq!(body.kind, "OSGymSandboxClaim");assert_eq!(body.metadata.namespace, NAMESPACE);+ let mut expected_spec = spec.clone();+ if expected_spec.bind_deadline.is_none() {+ expected_spec.bind_deadline = Some(DEFAULT_CLAIM_BIND_DEADLINE_SECONDS);+ }assert_eq!(serde_json::to_value(&body.spec).unwrap(),- serde_json::to_value(spec).unwrap()+ serde_json::to_value(expected_spec).unwrap());let name = &body.metadata.name;assert!(name.starts_with("claim-"), "unexpected claim name {name:?}");