Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/openshell-driver-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,5 @@ The gateway passes the `[openshell.drivers.docker]` table on stdin and gateway m
`serve` resolves the Docker socket from `socket_path`, then `DOCKER_HOST` and the usual locations, and pings it before it binds. The ping gets 20 seconds, so the gateway, which waits 30 seconds for a driver to start, receives the report instead of killing the driver. It exits 69 when Docker is not reachable and 78 when the table is invalid. Until `Configure` succeeds, both gRPC services (`ComputeDriver` and `ComputeDriverConfigurationUpdates`) return `UNAVAILABLE` and the driver creates no volumes, networks or containers. `preflight` validates the table without contacting Docker.

The gateway supplies the CA, the admission policy, its listener address, trusted runtime images from its environment, destination trust, and OTLP settings through `Configure`, so the table rejects `guest_tls_ca`, `allow_driver_config` and `resource_admission`. `grpc_endpoint` remains an optional override, and an `https://` endpoint needs the gateway CA.

`Configure` also says whether the gateway selected verified provider workload identity. A launched driver offers that mode only on an explicit `true`, and only when `provider_spiffe_workload_api_socket` is set, the supervisor reaches the gateway over HTTPS or a loopback IP address, and the supervisor image passes the probe.
3 changes: 3 additions & 0 deletions crates/openshell-driver-docker/src/image_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,9 @@ impl DockerComputeDriver {
.ok_or_else(|| invalid("Docker workload labels are missing"))?;
labels.insert(OPERATION_LABEL.into(), p.operation_id.clone());
labels.insert(REVISION_LABEL.into(), p.revision.to_string());
// The source can predate this label. An empty value keeps the new
// image's label off the workload.
labels.insert(LABEL_PROVIDER_LAUNCH_SPIFFE_ID.into(), String::new());
let container_name = source
.name
.as_deref()
Expand Down
100 changes: 100 additions & 0 deletions crates/openshell-driver-docker/src/image_update/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ impl Fixture {
.as_mut()
.unwrap()
.insert(REVISION_LABEL.into(), self.p().revision.to_string());
config
.labels
.as_mut()
.unwrap()
.insert(LABEL_PROVIDER_LAUNCH_SPIFFE_ID.into(), String::new());
target.state.as_mut().unwrap().status = Some(ContainerStateStatusEnum::CREATED);
target
}
Expand Down Expand Up @@ -497,6 +502,8 @@ async fn image_replacement_keeps_native_and_volume_identity_and_publishes_new_ev
assert_eq!(intent.sandbox_id, fixture.p().sandbox_id);
assert_eq!(intent.target_container.as_deref(), Some("container-B"));
assert_eq!(requests[8]["Image"], "sha256:corrected");
// An explicit empty value keeps the new image's label off the workload.
assert_eq!(requests[8]["Labels"][LABEL_PROVIDER_LAUNCH_SPIFFE_ID], "");
assert!(
!requests[8]["Env"]
.as_array()
Expand Down Expand Up @@ -917,6 +924,99 @@ async fn stopped_start_repairs_interrupted_launch_rotation_before_staging() {
);
}

#[tokio::test]
async fn start_replaces_only_a_supervisor_of_another_launch() {
use crate::tests::test_verified_launch_authentication as launch;

enum Outcome {
Kept,
Replaced,
Rejected,
}
use Outcome::{Kept, Rejected, Replaced};
// The launch SPIFFE ID names the runtime generation: a retried start
// carries the same launch and a later start carries another.
let (first, second) = ("generation-1", "generation-2");
// (generation the supervisor carries, generation started, the bundle
// names this sandbox, outcome)
for (carried, started, bundle_names_this_sandbox, outcome) in [
(Some(first), first, true, Kept),
(Some(first), second, true, Replaced),
(None, second, true, Replaced),
(Some(first), second, false, Rejected),
] {
let mut fixture = Fixture::new();
fixture.config.provider_workload_identity = true;
fixture
.call(fixture.apply_replies(), &fixture.request)
.await
.0
.unwrap();
let sandbox_id = fixture.p().sandbox_id.clone();
let (docker, server) = docker_api(fixture.start_replies(false)).await;
let mut driver = test_driver_with_config(fixture.config.clone());
driver.docker = Arc::new(docker);
// A supervisor that outlived its stopped workload.
let (shutdown, stopped) = oneshot::channel();
driver.control_processes.lock().await.insert(
sandbox_id.clone(),
DockerControlProcess {
shutdown: Some(shutdown),
intentional_shutdown: Arc::default(),
task: tokio::spawn(async move {
let _ = stopped.await;
}),
launch_spiffe_id: carried.and_then(|carried| {
launch(&sandbox_id, carried)
.supervisor
.provider_launch_spiffe_id
}),
},
);

let authentication = if bundle_names_this_sandbox {
launch(&sandbox_id, started)
} else {
launch("another-sandbox", started)
};
let error = Box::pin(driver.start_sandbox(
&sandbox_id,
&fixture.p().name,
started,
&serde_json::to_vec(&authentication).unwrap(),
None,
))
.await
.unwrap_err();
server.await.unwrap();
let kept = driver
.control_processes
.lock()
.await
.contains_key(&sandbox_id);
if matches!(outcome, Rejected) {
assert_eq!(error.code(), tonic::Code::InvalidArgument);
assert!(kept);
// The bundle was never saved, so no supervisor can carry its launch.
assert!(!fixture.directory.join(SUPERVISOR_AUTH_BUNDLE_FILE).exists());
continue;
}
// Deliberately omit the workspace-root staging input: reaching this
// gate proves the real Start path decided, without a fake workload.
assert!(error.message().contains("workspace for restart"), "{error}");
assert_eq!(kept, matches!(outcome, Kept));
// The supervisor that Start creates next is labeled from the saved bundle.
let mut sandbox = test_sandbox();
sandbox.id = sandbox_id;
let mut config = fixture.config.clone();
config.guest_tls = None;
let (_, label) = docker_supervisor_bundle_archive(&sandbox, &config)
.await
.unwrap();
assert_eq!(label, authentication.supervisor.provider_launch_spiffe_id);
}
}

#[tokio::test]
async fn interrupted_launch_pair_requires_stopped_workload_and_fresh_authentication() {
for (running, fresh_authentication, inspected_running) in [
Expand Down
Loading
Loading