Skip to content

Commit 2870236

Browse files
fix(server): notify watchers after atomic policy commits
Signed-off-by: Nave Cohen <[email protected]>
1 parent df69804 commit 2870236

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2234,6 +2234,7 @@ async fn handle_update_config_inner(
22342234
})?
22352235
};
22362236
response_annotations = committed_annotations;
2237+
state.sandbox_watch_bus.notify(&sandbox_id);
22372238

22382239
if backfill_policy.is_some() {
22392240
info!(
@@ -12517,6 +12518,7 @@ mod tests {
1251712518
)
1251812519
.await
1251912520
.unwrap();
12521+
let mut watch_rx = state.sandbox_watch_bus.subscribe("sb-same-hash");
1252012522

1252112523
let response = handle_update_config(
1252212524
&state,
@@ -12535,6 +12537,16 @@ mod tests {
1253512537
.into_inner();
1253612538

1253712539
assert_eq!(response.version, 2);
12540+
watch_rx
12541+
.try_recv()
12542+
.expect("new provenance revision must notify the sandbox watcher");
12543+
assert!(
12544+
matches!(
12545+
watch_rx.try_recv(),
12546+
Err(tokio::sync::broadcast::error::TryRecvError::Empty)
12547+
),
12548+
"one committed revision must wake the sandbox watcher exactly once"
12549+
);
1253812550
assert_eq!(
1253912551
response
1254012552
.annotations

0 commit comments

Comments
 (0)