diff --git a/crates/openshell-gateway/src/docker.rs b/crates/openshell-gateway/src/docker.rs index dfb68e20a5..e0b8105d72 100644 --- a/crates/openshell-gateway/src/docker.rs +++ b/crates/openshell-gateway/src/docker.rs @@ -15,8 +15,6 @@ use crate::local_driver::LocalDriver; pub const DOCKER: LocalDriver = LocalDriver { name: "docker", drop_legacy_keys: |_| {}, - // The in-process driver did not retry an unreachable daemon. - retry_unavailable: None, }; /// Detect Docker by starting its driver with the operator's table, so a diff --git a/crates/openshell-gateway/src/local_driver.rs b/crates/openshell-gateway/src/local_driver.rs index 3efee6cb35..caa22c8a8f 100644 --- a/crates/openshell-gateway/src/local_driver.rs +++ b/crates/openshell-gateway/src/local_driver.rs @@ -29,9 +29,6 @@ pub struct LocalDriver { /// Removes keys earlier releases accepted that the driver's strict table no /// longer does. The gateway warns about each, so the driver can reject them. pub drop_legacy_keys: fn(&mut toml::map::Map), - /// Start a named driver again this often while its backend is unreachable. - /// Drivers that never retried leave it unset. - pub retry_unavailable: Option, } /// The gateway's view of a driver's table: where its binary is, and the table @@ -163,13 +160,9 @@ impl LocalDriver { socket_dir, log_level: gateway_log_level, }; - let outcome = match self.retry_unavailable { - Some(retry) => { - launcher::launch_tolerating_unavailable(request, configure, on_exit, retry) - .await? - } - None => launcher::launch(request, configure, on_exit).await?, - }; + let outcome = + launcher::launch_tolerating_unavailable(request, configure, on_exit, BACKEND_RETRY) + .await?; match outcome { LaunchOutcome::Launched(launched) => launched, LaunchOutcome::InvalidConfig(reason) => { @@ -203,6 +196,9 @@ impl LocalDriver { } } -/// How long to wait between starts while a named driver's backend is down. -#[cfg(feature = "compute-driver-podman")] -pub const BACKEND_RETRY_DELAY: std::time::Duration = std::time::Duration::from_secs(2); +/// How often a named driver is started while its backend is unreachable, such +/// as a socket restarting during a package upgrade. +const BACKEND_RETRY: UnavailableRetry = UnavailableRetry { + attempts: 6, + delay: std::time::Duration::from_secs(2), +}; diff --git a/crates/openshell-gateway/src/podman.rs b/crates/openshell-gateway/src/podman.rs index 4623ec4fa7..027d2640e6 100644 --- a/crates/openshell-gateway/src/podman.rs +++ b/crates/openshell-gateway/src/podman.rs @@ -10,21 +10,11 @@ use openshell_server::{DriverDetection, DriverDetectionContext}; -use crate::launcher::UnavailableRetry; -use crate::local_driver::{BACKEND_RETRY_DELAY, LocalDriver}; - -/// How many times a named Podman is started while its socket is unreachable. -/// This keeps the bounded tolerance the in-process driver had, such as -/// `podman.socket` restarting during a package upgrade. -const START_ATTEMPTS: u32 = 6; +use crate::local_driver::LocalDriver; pub const PODMAN: LocalDriver = LocalDriver { name: "podman", drop_legacy_keys: drop_legacy_gateway_port, - retry_unavailable: Some(UnavailableRetry { - attempts: START_ATTEMPTS, - delay: BACKEND_RETRY_DELAY, - }), }; /// `main` accepted `gateway_port` and overwrote it with the gateway's diff --git a/docs/how-it-works/gateways/configuration.mdx b/docs/how-it-works/gateways/configuration.mdx index db461f8d66..4cc36f88f3 100644 --- a/docs/how-it-works/gateways/configuration.mdx +++ b/docs/how-it-works/gateways/configuration.mdx @@ -1569,7 +1569,7 @@ The gateway owns the admission policy (`allow_driver_config` and `resource_admis Set `driver_dir` in `[openshell.gateway]`. A `driver_dir` in a driver table is deprecated: the gateway removes it with a warning and uses it only when `[openshell.gateway]` sets none. The gateway looks for the driver binary in `driver_dir`, then in `~/.local/libexec/openshell`, `/usr/libexec/openshell`, `/usr/local/libexec/openshell`, and `/usr/local/libexec`, then next to the gateway binary. -When no driver is selected, the gateway tries Kubernetes, then Podman, then Docker. For Podman and Docker it starts the driver with the operator's table, so a configured `socket_path` is honored. The first driver that binds its socket is kept and configured, so detection never starts a driver it then stops. For Docker it does the same with the Docker table. A table that is invalid, or a socket that is not reachable, moves detection to the next candidate and logs the reason. A driver that crashes or times out stops startup. If a driver is selected by name, any such failure stops startup, except that Podman is started again a few times while its socket is unreachable, as the in-process driver retried. +When no driver is selected, the gateway tries Kubernetes, then Podman, then Docker. For Podman and Docker it starts the driver with the operator's table, so a configured `socket_path` is honored. The first driver that binds its socket is kept and configured, so detection never starts a driver it then stops. For Docker it does the same with the Docker table. A table that is invalid, or a socket that is not reachable, moves detection to the next candidate and logs the reason. A driver that crashes or times out stops startup. If a driver is selected by name, any such failure stops startup, except that the driver is started again up to six times, two seconds apart, while its backend is unreachable. On shutdown, the gateway stops sandboxes through each launched driver and then releases the driver with the launch protocol's `Shutdown` call. A driver defers a `SIGTERM` or `SIGINT` that reaches it from elsewhere, such as the signal a service manager sends to every process of the gateway's unit, until the gateway releases it, the gateway exits, or 30 seconds pass. Sandboxes therefore stop even when the whole unit is signalled.