From d54fc701609cc9260065a35248f94a4e8e30690d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Tue, 6 Aug 2024 19:29:40 +0200 Subject: [PATCH] fix(es-setup): retry docker pull on "i/o timeout" (#189988) --- packages/kbn-es/src/utils/docker.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/kbn-es/src/utils/docker.ts b/packages/kbn-es/src/utils/docker.ts index a0b11818ccd73..39e947793ae09 100644 --- a/packages/kbn-es/src/utils/docker.ts +++ b/packages/kbn-es/src/utils/docker.ts @@ -382,6 +382,12 @@ export async function maybeCreateDockerNetwork(log: ToolingLog) { log.indent(-4); } +const RETRYABLE_DOCKER_PULL_ERROR_MESSAGES = [ + 'connection refused', + 'i/o timeout', + 'Client.Timeout', +]; + /** * * Pull a Docker image if needed. Ensures latest image. @@ -407,8 +413,12 @@ ${message}`; { retries: 2, onFailedAttempt: (error) => { - // Only retry if `connection refused` is found in the error message. - if (!error?.message?.includes('connection refused')) { + // Only retry if retryable error messages are found in the error message. + if ( + RETRYABLE_DOCKER_PULL_ERROR_MESSAGES.every( + (msg) => !error?.message?.includes('connection refused') + ) + ) { throw error; } },