Skip to content

Commit 2c00ac3

Browse files
committed
fix(compute): preserve policy CAS and complete SDK checks
Validate explicit policy versions after the lifecycle reload. Carry the ingress and resource SDK compatibility corrections into the combined source, including the legacy example response default. Refs NVIDIA#5114 Signed-off-by: Shiju <[email protected]>
1 parent 223f9ff commit 2c00ac3

10 files changed

Lines changed: 43 additions & 6 deletions

File tree

‎crates/openshell-server/src/grpc/policy.rs‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ use crate::pagination::Pagination;
3838
#[cfg(test)]
3939
use crate::persistence::ObjectType;
4040
use crate::persistence::{
41-
DraftChunkRecord, ObjectId, ObjectListQuery, ObjectName, ObjectWorkspace, PolicyRecord, Store,
41+
DraftChunkRecord, GetResourceVersion, ObjectId, ObjectListQuery, ObjectName, ObjectWorkspace,
42+
PolicyRecord, Store,
4243
};
4344
use crate::policy_store::{AtomicPolicyRevisionWrite, PolicyStoreExt};
4445
use crate::provider_profile_sources::EffectiveProviderProfileCatalog;
@@ -4730,6 +4731,15 @@ async fn handle_update_config_inner(
47304731
"sandbox scope changed while waiting for policy update; retry explicitly",
47314732
));
47324733
}
4734+
let current_version = current.get_resource_version();
4735+
if req.expected_resource_version != 0 && req.expected_resource_version != current_version {
4736+
return Err(super::persistence_error_to_status(
4737+
crate::persistence::PersistenceError::Conflict {
4738+
current_resource_version: Some(current_version),
4739+
},
4740+
"update sandbox policy",
4741+
));
4742+
}
47334743
let sandbox = current;
47344744
response_annotations = sandbox_metadata_annotations(&sandbox);
47354745
if has_merge_ops {

‎examples/isolation-backend-v8/src/driver.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl compute_driver_server::ComputeDriver for DriverService {
384384
.as_ref()
385385
.ok_or_else(|| Status::invalid_argument("sandbox required"))?,
386386
)?;
387-
Ok(Response::new(ValidateSandboxCreateResponse {}))
387+
Ok(Response::new(ValidateSandboxCreateResponse::default()))
388388
}
389389
async fn create_sandbox(
390390
&self,

‎python/openshell/sandbox_test.py‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2014,6 +2014,7 @@ def __init__(
20142014
def Health(
20152015
self, request: object, timeout: float | None = None
20162016
) -> openshell_pb2.HealthResponse:
2017+
_ = request, timeout
20172018
return openshell_pb2.HealthResponse(
20182019
supports_sampled_resource_budget=self.sampled_budget_ack
20192020
)
@@ -2372,10 +2373,10 @@ def test_sampled_budget_requires_gateway_acknowledgement(template: bool) -> None
23722373
stub = _FakeSandboxStub()
23732374
budget = sandbox_pb2.SampledResourceBudget(resident_bytes=4096)
23742375
if template:
2375-
client = _template_client_with_fake_stub(stub)
2376+
template_client = _template_client_with_fake_stub(stub)
23762377

23772378
def write() -> object:
2378-
return client.create(
2379+
return template_client.create(
23792380
workspace="default", name="budget", sampled_budget=budget
23802381
)
23812382
else:
@@ -2862,10 +2863,16 @@ def test_sandbox_ref_exposes_host_identity_and_accepts_legacy_response() -> None
28622863
proto.host_key_fingerprint = "SHA256:expected"
28632864
assert _sandbox_ref(proto).host_key_fingerprint == "SHA256:expected"
28642865
assert _sandbox_ref(proto).status.ingress_admission is None
2865-
proto.status.ingress_admission.scope = 3
2866+
proto.status.ingress_admission.scope = (
2867+
sandbox_pb2.INGRESS_SCOPE_SHARED_HOST_LOOPBACK
2868+
)
28662869
proto.status.ingress_admission.ports.append(8080)
28672870
admission = _sandbox_ref(proto).status.ingress_admission
2868-
assert admission is not None and admission.ports == (8080,) and admission.scope == 3
2871+
assert (
2872+
admission is not None
2873+
and admission.ports == (8080,)
2874+
and admission.scope == sandbox_pb2.INGRESS_SCOPE_SHARED_HOST_LOOPBACK
2875+
)
28692876
proto.status.ingress_admission.ports[0] = 9090
28702877
assert admission.ports == (8080,)
28712878

‎sdk/go/openshell/v1/health.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ type HealthInterface interface {
5454
GetCurrentUser(ctx context.Context) (*CurrentUser, error)
5555
}
5656

57+
// ResourceCapabilities reports the configured compute driver's resource guarantees.
5758
type ResourceCapabilities = types.ResourceCapabilities
59+
60+
// ResourceDomainCapabilities describes resource limit and request enforcement.
5861
type ResourceDomainCapabilities = types.ResourceDomainCapabilities
62+
63+
// ResourceEnforcement identifies the mechanism and scope of a resource guarantee.
5964
type ResourceEnforcement = types.ResourceEnforcement
65+
66+
// GPUResourceCapabilities describes supported GPU selection methods.
6067
type GPUResourceCapabilities = types.GPUResourceCapabilities
68+
69+
// SampledBudgetCapabilities describes supported sampled workload budgets.
6170
type SampledBudgetCapabilities = types.SampledBudgetCapabilities

‎sdk/go/openshell/v1/internal/converter/sandbox.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ func resourceDurationToProto(d *types.ResourceDuration) *durationpb.Duration {
652652
return &durationpb.Duration{Seconds: d.Seconds, Nanos: d.Nanos}
653653
}
654654

655+
// SampledBudgetFromProto copies a protobuf budget into the SDK model.
655656
func SampledBudgetFromProto(b *sandboxpb.SampledResourceBudget) *types.SampledResourceBudget {
656657
if b == nil {
657658
return nil
@@ -663,6 +664,8 @@ func SampledBudgetFromProto(b *sandboxpb.SampledResourceBudget) *types.SampledRe
663664
}
664665
return result
665666
}
667+
668+
// SampledBudgetToProto copies an SDK budget into its protobuf form.
666669
func SampledBudgetToProto(b *types.SampledResourceBudget) *sandboxpb.SampledResourceBudget {
667670
if b == nil {
668671
return nil

‎sdk/go/openshell/v1/resource.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
// SPDX-License-Identifier: Apache-2.0
3+
34
package v1
45

56
import (

‎sdk/go/openshell/v1/sandbox.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type SandboxSuspendResumeInterface interface {
122122
// WaitSuspended polls until the sandbox reaches the Suspended phase.
123123
WaitSuspended(ctx context.Context, workspace, name string, opts ...WaitOptions) (*Sandbox, error)
124124
}
125+
125126
// ResourceDuration preserves protobuf duration precision and range.
126127
type ResourceDuration = types.ResourceDuration
127128

‎sdk/go/openshell/v1/types.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type SandboxIngressAdmission = types.SandboxIngressAdmission
6464
// IngressScope identifies the admitted loopback namespace.
6565
type IngressScope = types.IngressScope
6666

67+
// IngressScope values identify the admitted loopback namespace.
6768
const (
6869
IngressUnknown = types.IngressUnknown
6970
IngressUnsupported = types.IngressUnsupported

‎sdk/go/openshell/v1/types/health.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,27 @@ type ResourceCapabilities struct {
7777
SampledBudget *SampledBudgetCapabilities
7878
}
7979

80+
// ResourceDomainCapabilities describes resource limit and request enforcement.
8081
type ResourceDomainCapabilities struct {
8182
LimitSupported bool
8283
LimitEnforcement *ResourceEnforcement
8384
RequestEnforcement *ResourceEnforcement
8485
}
8586

87+
// ResourceEnforcement identifies the mechanism and scope of a resource guarantee.
8688
type ResourceEnforcement struct {
8789
// Unknown enum values are preserved as "Unknown", never inferred as support.
8890
Kind string
8991
Scope string
9092
}
9193

94+
// GPUResourceCapabilities describes supported GPU selection methods.
9295
type GPUResourceCapabilities struct {
9396
DefaultSelectionSupported bool
9497
CountSelectionSupported bool
9598
}
9699

100+
// SampledBudgetCapabilities describes supported sampled workload budgets.
97101
type SampledBudgetCapabilities struct {
98102
CPUTimeSupported bool
99103
ResidentBytesSupported bool

‎sdk/go/openshell/v1/types/sandbox.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ type DetachProviderResult struct {
283283
// IngressScope describes the network namespace of admitted service targets.
284284
type IngressScope string
285285

286+
// IngressScope values identify the admitted loopback namespace.
286287
const (
287288
IngressUnknown IngressScope = "unknown"
288289
IngressUnsupported IngressScope = "unsupported"

0 commit comments

Comments
 (0)