Skip to content

Commit 23c1149

Browse files
committed
fix(policy): enforce requested versions after lifecycle reload
Check an explicit resource version against the locked sandbox snapshot before policy deduplication. Preserve zero-version compatibility and lifecycle fencing. The existing concurrent-backfill regression now rejects both stale requests. Refs #5109 Signed-off-by: Shiju <shiju@nvidia.com>
1 parent a2a21f3 commit 23c1149

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ use crate::compute::MutationScope;
3737
use crate::pagination::Pagination;
3838
use crate::persistence::ObjectType;
3939
use crate::persistence::{
40-
DraftChunkRecord, ObjectId, ObjectListQuery, ObjectName, ObjectWorkspace, PolicyRecord, Store,
40+
DraftChunkRecord, GetResourceVersion, ObjectId, ObjectListQuery, ObjectName, ObjectWorkspace,
41+
PolicyRecord, Store,
4142
};
4243
use crate::policy_store::{AtomicPolicyRevisionWrite, PolicyStoreExt};
4344
use crate::provider_profile_sources::EffectiveProviderProfileCatalog;
@@ -4675,6 +4676,15 @@ async fn handle_update_config_inner(
46754676
"sandbox scope changed while waiting for policy update; retry explicitly",
46764677
));
46774678
}
4679+
let current_version = current.get_resource_version();
4680+
if req.expected_resource_version != 0 && req.expected_resource_version != current_version {
4681+
return Err(super::persistence_error_to_status(
4682+
crate::persistence::PersistenceError::Conflict {
4683+
current_resource_version: Some(current_version),
4684+
},
4685+
"update sandbox policy",
4686+
));
4687+
}
46784688
let sandbox = current;
46794689
response_annotations = sandbox_metadata_annotations(&sandbox);
46804690
if has_merge_ops {

0 commit comments

Comments
 (0)