diff --git a/.env b/.env index f65b31f..95ec4d0 100644 --- a/.env +++ b/.env @@ -15,3 +15,4 @@ OPR_EXECUTOR_DOCKER_HUB_PASSWORD= OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v5 OPR_EXECUTOR_RETRY_ATTEMPTS=5 OPR_EXECUTOR_RETRY_DELAY_MS=500 +OPR_EXECUTOR_CONNECT_TIMEOUT= diff --git a/docker-compose.yml b/docker-compose.yml index bc09321..306fb30 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,6 +48,7 @@ services: - OPR_EXECUTOR_RETRY_ATTEMPTS - OPR_EXECUTOR_RETRY_DELAY_MS - OPR_EXECUTOR_IMAGE_PULL + - OPR_EXECUTOR_CONNECT_TIMEOUT volumes: openruntimes-builds: diff --git a/src/Executor/Runner/Docker.php b/src/Executor/Runner/Docker.php index f7cdab2..c17b370 100644 --- a/src/Executor/Runner/Docker.php +++ b/src/Executor/Runner/Docker.php @@ -788,7 +788,7 @@ public function createExecution( \curl_setopt($ch, CURLOPT_POST, true); \curl_setopt($ch, CURLOPT_POSTFIELDS, $body); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int)Http::getEnv('OPR_EXECUTOR_CONNECT_TIMEOUT', '10')); \curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', @@ -905,7 +905,7 @@ public function createExecution( \curl_setopt($ch, CURLOPT_POSTFIELDS, $body); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); \curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); - \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); + \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int)Http::getEnv('OPR_EXECUTOR_CONNECT_TIMEOUT', '10')); \curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', @@ -995,7 +995,7 @@ public function createExecution( }); \curl_setopt($ch, CURLOPT_TIMEOUT, $timeout + 5); // Gives extra 5s after safe timeout to recieve response - \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); + \curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, (int)Http::getEnv('OPR_EXECUTOR_CONNECT_TIMEOUT', '5')); if ($logging === true) { $headers['x-open-runtimes-logging'] = 'enabled'; } else {