mirror of
https://github.com/floci-io/floci.git
synced 2026-11-28 08:09:43 -05:00
feat(core): make the Docker call timeout configurable (#5431)
* feat(core): make the Docker call timeout configurable Ordinary Docker calls failed after a hard-coded five minutes without a response. floci.docker.api-timeout-seconds (FLOCI_DOCKER_API_TIMEOUT_SECONDS) now sets it for both pools, defaulting to 300 so nothing changes by default; a shorter value bounds how long a hung daemon can hold a request. Like the connection request timeout, it must be at least 1, because httpclient5 reads 0 as no limit. Long-lived streams (container waits, exec and attach output, followed logs, streamed stats, events, image pulls and builds) stay exempt. Signed-off-by: Hector Ventura <hectorvent@gmail.com> * docs(core): say the Docker call timeout applies to each attempt The control-plane pool retries a request that is safe to repeat up to six times, and a response timeout is one of the failures it retries. The docs, the config Javadoc and the application.yml comment said the setting bounds a request; it bounds each attempt, so a silent daemon can hold a replayable request for about six times the limit, plus backoff. Signed-off-by: Hector Ventura <hectorvent@gmail.com> --------- Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
61fe304619
commit
98100054a8
6 files changed
+71
-5
No files matched your search
@@ -3540,6 +3540,16 @@ public interface EmulatorConfig {
|
||||
@WithDefault("30")
|
||||
int connectionRequestTimeoutSeconds();
|
||||
|
||||
/**
|
||||
* How long a Docker call waits for the daemon's response before it fails, in seconds, for
|
||||
* both pools. The limit is per attempt: a control-plane request that is safe to repeat is
|
||||
* tried up to six times. Requests that hold a stream open for as long as a container runs (container
|
||||
* waits, exec and attach output, followed logs, streamed stats, events, image pulls and
|
||||
* builds) are exempt, since they can stay silent while healthy.
|
||||
*/
|
||||
@WithDefault("300")
|
||||
int apiTimeoutSeconds();
|
||||
|
||||
/**
|
||||
* Optional namespace inserted into Floci-managed child container and volume names.
|
||||
* Useful when multiple Floci processes share one Docker daemon.
|
||||
|
||||
+7
-2
@@ -419,6 +419,10 @@ public class DockerClientProducer {
|
||||
"FLOCI_DOCKER_CONNECTION_REQUEST_TIMEOUT_SECONDS");
|
||||
}
|
||||
|
||||
static int validateApiTimeoutSeconds(int seconds) {
|
||||
return requireAtLeastOne(seconds, "floci.docker.api-timeout-seconds", "FLOCI_DOCKER_API_TIMEOUT_SECONDS");
|
||||
}
|
||||
|
||||
private static int requireAtLeastOne(int value, String setting, String envVar) {
|
||||
if (value < 1) {
|
||||
throw new IllegalArgumentException(setting + " (" + envVar + ") must be at least 1, got: " + value);
|
||||
@@ -497,18 +501,19 @@ public class DockerClientProducer {
|
||||
role, maxConnections, clientConfig.getDockerHost());
|
||||
|
||||
return DockerClientImpl.getInstance(clientConfig, wrapForRole(newHttpClient(clientConfig, maxConnections,
|
||||
Duration.ofSeconds(validateApiTimeoutSeconds(config.docker().apiTimeoutSeconds())),
|
||||
Duration.ofSeconds(validateConnectionRequestTimeoutSeconds(
|
||||
config.docker().connectionRequestTimeoutSeconds()))), role));
|
||||
}
|
||||
|
||||
static FlociDockerHttpClient newHttpClient(DefaultDockerClientConfig clientConfig, int maxConnections,
|
||||
Duration connectionRequestTimeout) {
|
||||
Duration apiTimeout, Duration connectionRequestTimeout) {
|
||||
return new FlociDockerHttpClient.Builder()
|
||||
.dockerHost(clientConfig.getDockerHost())
|
||||
.sslConfig(clientConfig.getSSLConfig())
|
||||
.maxConnections(maxConnections)
|
||||
.connectionTimeout(Duration.ofSeconds(30))
|
||||
.responseTimeout(Duration.ofMinutes(5))
|
||||
.responseTimeout(apiTimeout)
|
||||
.connectionRequestTimeout(connectionRequestTimeout)
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user