Skip to content

Commit 758a70e

Browse files
committed
fix(sandbox): adapt reverse control to published backend protocol
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 2650b4f commit 758a70e

4 files changed

Lines changed: 25 additions & 14 deletions

File tree

‎crates/openshell-core/src/isolation_registration.rs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ impl SandboxTransport {
5151
.iter()
5252
.all(|address| address.port() != 0 && !address.ip().is_unspecified())
5353
}
54-
Self::RuntimeInitiatedTcp { authority, listen_address } => {
55-
!authority.is_empty() && listen_address.port() != 0
56-
}
54+
Self::RuntimeInitiatedTcp {
55+
authority,
56+
listen_address,
57+
} => !authority.is_empty() && listen_address.port() != 0,
5758
Self::Vsock { guest_cid, port } => {
5859
*guest_cid >= 3 && *guest_cid != u32::MAX && *port != 0 && *port != u32::MAX
5960
}
@@ -91,6 +92,12 @@ pub fn validate_registrations(registrations: &[BackendRegistration]) -> Result<(
9192
let mut names = BTreeSet::new();
9293
for registration in registrations {
9394
validate_backend_name(&registration.name)?;
95+
if matches!(
96+
registration.endpoint,
97+
SandboxTransport::RuntimeInitiatedTcp { .. }
98+
) {
99+
return Err("runtime-initiated control is not a registered backend endpoint");
100+
}
94101
if !names.insert(&registration.name) {
95102
return Err("duplicate isolation backend registration");
96103
}

‎crates/openshell-driver-kubernetes/src/isolation.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ impl KubernetesOuterFenceEvidence<'_> {
7575
"Kubernetes provisioning evidence is incomplete".to_string(),
7676
));
7777
}
78-
if self.runtime_control_policy.as_ref().is_some_and(|control| !control.is_bound()) {
79-
return Err(BackendError::Descriptor("Kubernetes control policy evidence is incomplete".into()));
78+
if self
79+
.runtime_control_policy
80+
.as_ref()
81+
.is_some_and(|control| !control.is_bound())
82+
{
83+
return Err(BackendError::Descriptor(
84+
"Kubernetes control policy evidence is incomplete".into(),
85+
));
8086
}
8187
let encoded = serde_json::to_vec(self).map_err(|error| {
8288
BackendError::Descriptor(format!("encode Kubernetes outer fence evidence: {error}"))

‎crates/openshell-sandbox-backend/src/runtime.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,7 @@ impl OpenShellRuntimeBackend {
183183
) -> Result<(Option<String>, bool), BackendError> {
184184
let mut client = BoundaryClient::new(descriptor, bearer);
185185
client.transport = transport;
186-
match client.call_idempotent(Request::DiscoverPolicy).await? {
187-
Response::ImagePolicy { yaml, invalid } => Ok((yaml, invalid)),
188-
_ => Err(BackendError::Descriptor(
189-
"expected image policy discovery response".to_string(),
190-
)),
191-
}
186+
client.discover_policy().await
192187
}
193188

194189
pub fn new(
@@ -1966,7 +1961,8 @@ impl BoundaryClient {
19661961
let transport = Arc::new(TransportAbort::default());
19671962
let connector_transport = transport.clone();
19681963
let authority = match &runtime_descriptor.transport {
1969-
SandboxTransport::Tcp { authority, .. } => authority.as_str(),
1964+
SandboxTransport::Tcp { authority, .. }
1965+
| SandboxTransport::RuntimeInitiatedTcp { authority, .. } => authority.as_str(),
19701966
SandboxTransport::Unix { .. } | SandboxTransport::Vsock { .. } => {
19711967
"boundary.openshell.internal"
19721968
}
@@ -2610,6 +2606,7 @@ mod tests {
26102606
let result = OpenShellRuntimeBackend::discover_policy(
26112607
tls_runtime_descriptor(address, client_tls),
26122608
test_bearer(&"a".repeat(32)),
2609+
BoundaryTransport::default(),
26132610
)
26142611
.await;
26152612
assert!(
@@ -2652,6 +2649,7 @@ mod tests {
26522649
let result = OpenShellRuntimeBackend::discover_policy(
26532650
tls_runtime_descriptor(address, client_tls),
26542651
test_bearer(&"a".repeat(32)),
2652+
BoundaryTransport::default(),
26552653
)
26562654
.await;
26572655
assert!(

‎crates/openshell-sandbox-backend/src/runtime/test_support.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ fn client(peer: Peer) -> Arc<BoundaryClient> {
723723
.unwrap();
724724
let mut client =
725725
BoundaryClient::with_backend(descriptor, bearer, crate::BACKEND_NAME.into(), vec![]);
726-
client.connector = Some(Arc::new(Connector {
726+
client.transport = crate::BoundaryTransport::connector(Arc::new(Connector {
727727
peer,
728728
address,
729729
task,
@@ -861,7 +861,7 @@ pub fn backend(
861861
)
862862
.unwrap();
863863
let mut backend = crate::OpenShellRuntimeBackend::new(ca, credentials, bearer);
864-
backend.connector.clone_from(&peer.connector);
864+
backend.transport.clone_from(&peer.transport);
865865
backend.delegated = Some(crate::runtime::DelegatedRuntime {
866866
backend_name: name,
867867
descriptor,

0 commit comments

Comments
 (0)