Skip to content

Commit 3edfe2e

Browse files
committed
refactor(supervisor): use session-control wire types for instance status and trace context
Drop the supervisor's duplicate SandboxInstancePhase, SandboxInstanceStatus, and TraceContext families. The sandbox instance host reports SandboxInstanceStatusReport directly, with its key as the route, so the shared host no longer converts or re-keys status, lists, or removal results. SandboxInstanceConfig carries RegistrationTraceContext and the dedicated process reads it through trace_context_from_environment. No wire definitions change. Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent b3de0e9 commit 3edfe2e

4 files changed

Lines changed: 96 additions & 146 deletions

File tree

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

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use std::time::Duration;
3838
use tracing::{Instrument as _, debug, info, warn};
3939

4040
use openshell_core::PolicyValidationFailureMode;
41+
use openshell_sandbox_backend::session_control::RegistrationTraceContext;
4142

4243
use openshell_ocsf::{
4344
ActionId, ActivityId, AppLifecycleBuilder, ConfidenceId, ConfigStateChangeBuilder,
@@ -741,27 +742,18 @@ pub fn sandbox_instance_event_context(
741742
}
742743
}
743744

744-
/// W3C trace context of the operation that launched a sandbox generation.
745-
#[derive(Clone, Debug, PartialEq, Eq)]
746-
pub struct TraceContext {
747-
pub traceparent: String,
748-
pub tracestate: Option<String>,
749-
}
750-
751-
impl TraceContext {
752-
/// The context a driver passed to a dedicated supervisor process.
753-
#[must_use]
754-
pub fn from_environment() -> Option<Self> {
755-
let traceparent = std::env::var(openshell_otel::TRACEPARENT_ENV)
745+
/// The trace context a driver passed to a dedicated supervisor process.
746+
#[must_use]
747+
pub fn trace_context_from_environment() -> Option<RegistrationTraceContext> {
748+
let traceparent = std::env::var(openshell_otel::TRACEPARENT_ENV)
749+
.ok()
750+
.filter(|value| !value.is_empty())?;
751+
Some(RegistrationTraceContext {
752+
traceparent,
753+
tracestate: std::env::var(openshell_otel::TRACESTATE_ENV)
756754
.ok()
757-
.filter(|value| !value.is_empty())?;
758-
Some(Self {
759-
traceparent,
760-
tracestate: std::env::var(openshell_otel::TRACESTATE_ENV)
761-
.ok()
762-
.filter(|value| !value.is_empty()),
763-
})
764-
}
755+
.filter(|value| !value.is_empty()),
756+
})
765757
}
766758

767759
/// Trusted launch inputs of one supervised sandbox instance.
@@ -795,7 +787,7 @@ pub struct SandboxInstanceConfig {
795787
pub admitted_isolation_backend: Option<String>,
796788
pub main_exit_marker: Option<std::path::PathBuf>,
797789
/// Parent of the startup span.
798-
pub trace_context: Option<TraceContext>,
790+
pub trace_context: Option<RegistrationTraceContext>,
799791
/// SPIFFE Workload API socket for provider token grants; absent fails closed.
800792
pub provider_workload_api_socket: Option<std::path::PathBuf>,
801793
pub proxy_tls: openshell_supervisor_network::run::ProxyTlsFiles,

‎crates/openshell-supervisor/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn main() -> Result<()> {
586586
auth_bundle,
587587
admitted_isolation_backend: Some(admitted_backend),
588588
main_exit_marker: args.main_exit_marker,
589-
trace_context: openshell_supervisor::TraceContext::from_environment(),
589+
trace_context: openshell_supervisor::trace_context_from_environment(),
590590
provider_workload_api_socket: std::env::var_os(
591591
openshell_core::sandbox_env::PROVIDER_SPIFFE_WORKLOAD_API_SOCKET,
592592
)

0 commit comments

Comments
 (0)