From 196d2afce8553d55528c04f9c02c091c9f5a7da7 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Fri, 17 Jan 2025 14:31:33 +0000 Subject: [PATCH 1/2] test(Makefile): retry pulling postgres in test-postgres-docker --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 7a0c892218a99..1778fbd2c9e97 100644 --- a/Makefile +++ b/Makefile @@ -864,6 +864,12 @@ test-migrations: test-postgres-docker # NOTE: we set --memory to the same size as a GitHub runner. test-postgres-docker: docker rm -f test-postgres-docker-${POSTGRES_VERSION} || true + + # Try pulling up to three times to avoid CI flakes. + docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} || \ + docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} || \ + docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} + # Make sure to not overallocate work_mem and max_connections as each # connection will be allowed to use this much memory. Try adjusting # shared_buffers instead, if needed. From 220a38afc03fdd6e1f5fca489734f450c21c5044 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Fri, 17 Jan 2025 14:48:02 +0000 Subject: [PATCH 2/2] make retry nicer --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1778fbd2c9e97..ece33b90194a3 100644 --- a/Makefile +++ b/Makefile @@ -866,9 +866,16 @@ test-postgres-docker: docker rm -f test-postgres-docker-${POSTGRES_VERSION} || true # Try pulling up to three times to avoid CI flakes. - docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} || \ - docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} || \ - docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} + docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} || { + retries=2 + for try in $(seq 1 ${retries}); do + echo "Failed to pull image, retrying (${try}/${retries})..." + sleep 1 + if docker pull gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION}; then + break + fi + done + } # Make sure to not overallocate work_mem and max_connections as each # connection will be allowed to use this much memory. Try adjusting