Skip to content

Commit 03c6d6e

Browse files
committed
chore(supervisor): merge instance lifecycle owner into provider token resolvers
Merge refactor/4700-instance-lifecycle-owner/drew, which replaces the supervisor's duplicate instance status and trace context types with the session-control wire types. Keeps the gateway provider identity source and token resolver selection of this branch. Signed-off-by: Drew Newberry <anewberry@nvidia.com>
2 parents 36dcd00 + 0aafe59 commit 03c6d6e

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
/// How this instance obtains provider access tokens.
800792
pub provider_identity: openshell_supervisor_network::run::ProviderIdentitySource,
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_identity:
591591
openshell_supervisor_network::run::ProviderIdentitySource::WorkloadApi(
592592
std::env::var_os(

0 commit comments

Comments
 (0)