Skip to content

Commit b85007b

Browse files
committed
feat(sdk/rust)!: align portable resource requirements
Expose the shared typed ResourceRequirements model for inline and reusable-template workloads and remove the template-only SandboxResources alias. BREAKING CHANGE: SandboxResources is removed; reusable workload templates now use ResourceRequirements with typed CPU and memory fields. Part of #2838 Signed-off-by: Evan Lezar <[email protected]>
1 parent ddbb259 commit b85007b

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎crates/openshell-sdk/src/client.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,8 @@ fn create_sandbox_request(spec: SandboxSpec) -> proto::CreateSandboxRequest {
11851185
});
11861186
let resource_requirements = gpu.then_some(proto::ResourceRequirements {
11871187
gpu: Some(proto::GpuResourceRequirements { count: None }),
1188+
cpu: None,
1189+
memory: None,
11881190
});
11891191
proto::CreateSandboxRequest {
11901192
request_id: String::new(),

‎crates/openshell-sdk/src/lib.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ pub use error::SdkError;
5050
pub use pagination::{Page, Pager};
5151
pub use refresh::{Refresh, RefreshError, RefreshedToken, TokenSource};
5252
pub use types::{
53-
DeleteOptions, DeletionOutcome, DeletionResult, ExecOptions, ExecResult, Health, ListOptions,
54-
SandboxPhase, SandboxRef, SandboxResources, SandboxServiceLevel, SandboxSpec, SandboxStartup,
55-
SandboxTemplateCreateSpec, SandboxTemplateListOptions, SandboxWorkloadConfig,
53+
CpuResourceRequirements, DeleteOptions, DeletionOutcome, DeletionResult, ExecOptions,
54+
ExecResult, GpuResourceRequirements, Health, ListOptions, MemoryResourceRequirements,
55+
ResourceRequirements, SandboxPhase, SandboxRef, SandboxServiceLevel, SandboxSpec,
56+
SandboxStartup, SandboxTemplateCreateSpec, SandboxTemplateListOptions, SandboxWorkloadConfig,
5657
SandboxWorkloadTemplate, SandboxWorkloadTemplateProvenance, SandboxWorkloadTemplateSpec,
5758
ServiceStatus, WorkspaceRef,
5859
};

‎crates/openshell-sdk/src/raw.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use openshell_core::proto::{
2828
ListSandboxTemplatesRequest, ListSandboxesRequest, ListWorkspacesRequest,
2929
ProviderDesiredIdentity, ProviderMutationKind, ProviderMutationReceipt,
3030
ProviderReadinessObservation, ProviderReadinessReason, ProviderReadinessState,
31-
ProviderReadinessStatus, Sandbox, SandboxPhase as ProtoSandboxPhase, SandboxResources,
31+
ProviderReadinessStatus, ResourceRequirements, Sandbox, SandboxPhase as ProtoSandboxPhase,
3232
SandboxServiceLevel, SandboxSpec as ProtoSandboxSpec, SandboxStartup, SandboxTemplate,
3333
SandboxTemplateResponse, SandboxWorkloadConfig, SandboxWorkloadTemplate,
3434
SandboxWorkloadTemplateProvenance, SandboxWorkloadTemplateSpec,

‎crates/openshell-sdk/src/types.rs‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,17 @@ pub type SandboxWorkloadTemplateSpec = proto::SandboxWorkloadTemplateSpec;
195195
/// Portable sandbox workload configuration for template-backed sandboxes.
196196
pub type SandboxWorkloadConfig = proto::SandboxWorkloadConfig;
197197

198-
/// Portable resource requirements for template-backed sandboxes.
199-
pub type SandboxResources = proto::SandboxResources;
198+
/// Portable resource requirements shared by inline and template-backed sandboxes.
199+
pub type ResourceRequirements = proto::ResourceRequirements;
200+
201+
/// CPU resource requirements for a sandbox workload.
202+
pub type CpuResourceRequirements = proto::CpuResourceRequirements;
203+
204+
/// Memory resource requirements for a sandbox workload.
205+
pub type MemoryResourceRequirements = proto::MemoryResourceRequirements;
206+
207+
/// GPU resource requirements for a sandbox workload.
208+
pub type GpuResourceRequirements = proto::GpuResourceRequirements;
200209

201210
/// Desired service level for sandboxes created from a template.
202211
pub type SandboxServiceLevel = proto::SandboxServiceLevel;

‎crates/openshell-sdk/tests/client_mock.rs‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,16 @@ fn workload_template_proto(name: &str, workspace: &str) -> proto::SandboxWorkloa
147147
workload: Some(proto::SandboxWorkloadConfig {
148148
image: format!("ghcr.io/test/{name}:latest"),
149149
environment: HashMap::new(),
150-
resources: Some(proto::SandboxResources {
151-
cpu: "1".to_string(),
152-
memory: "512Mi".to_string(),
153-
..proto::SandboxResources::default()
150+
resources: Some(proto::ResourceRequirements {
151+
cpu: Some(proto::CpuResourceRequirements {
152+
quantity: Some("1".to_string()),
153+
}),
154+
memory: Some(proto::MemoryResourceRequirements {
155+
quantity: Some("512Mi".to_string()),
156+
}),
157+
..Default::default()
154158
}),
159+
..Default::default()
155160
}),
156161
driver_config: None,
157162
desired_service_level: None,

0 commit comments

Comments
 (0)