From 8bfd1f256079ba3d2cbd51c62fca68ec0041c0ec Mon Sep 17 00:00:00 2001 From: crazyracer98 <8631139+crazyracer98@users.noreply.github.com> Date: Fri, 13 Nov 2026 07:38:05 +0000 Subject: [PATCH 1/3] fix(install-lib): retry TLS handshake failures and apt-get update in the shared library (RETRY) curl exit 35 (e.g. repo.mosquitto.org's TLS unexpected eof) joins the retried exits in _il_curl, and il_apt_add_repo's apt-get update gets Acquire::Retries=3. Copied to every feature; all features bumped to 1.0.1. --- common/install-lib.sh | 9 +++++---- ...pins-from-option-env-or-pins-file-with-no-defaults.md | 2 +- src/cli-claude-code/devcontainer-feature.json | 2 +- src/cli-claude-code/install-lib.sh | 9 +++++---- src/cli-keycloak/devcontainer-feature.json | 2 +- src/cli-keycloak/install-lib.sh | 9 +++++---- src/cli-mosquitto/devcontainer-feature.json | 2 +- src/cli-mosquitto/install-lib.sh | 9 +++++---- src/cli-opencode/devcontainer-feature.json | 2 +- src/cli-opencode/install-lib.sh | 9 +++++---- src/cli-postgres-client/devcontainer-feature.json | 2 +- src/cli-postgres-client/install-lib.sh | 9 +++++---- src/cli-rustfs/devcontainer-feature.json | 2 +- src/cli-rustfs/install-lib.sh | 9 +++++---- src/cli-s5cmd/devcontainer-feature.json | 2 +- src/cli-s5cmd/install-lib.sh | 9 +++++---- src/cli-valkey/devcontainer-feature.json | 2 +- src/cli-valkey/install-lib.sh | 9 +++++---- src/ssl-ca/devcontainer-feature.json | 2 +- src/ssl-ca/install-lib.sh | 9 +++++---- 20 files changed, 60 insertions(+), 50 deletions(-) diff --git a/common/install-lib.sh b/common/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/common/install-lib.sh +++ b/common/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/docs/adrs/0002-resolve-pins-from-option-env-or-pins-file-with-no-defaults.md b/docs/adrs/0002-resolve-pins-from-option-env-or-pins-file-with-no-defaults.md index 4920b75..901e837 100644 --- a/docs/adrs/0002-resolve-pins-from-option-env-or-pins-file-with-no-defaults.md +++ b/docs/adrs/0002-resolve-pins-from-option-env-or-pins-file-with-no-defaults.md @@ -102,7 +102,7 @@ runs `curl -fsSL --connect-timeout 10 --retry 3 --retry-max-time 60 --retry-connrefused`. curl itself retries timeouts, `ECONNREFUSED` and HTTP 408/429/5xx. It doesn't retry other connect errors such as `EHOSTUNREACH` or `ENETUNREACH`, so the library retries DNS and connect -failures (curl exit 6/7), resets and truncated transfers (18/52/55/56) up +failures (curl exit 6/7), TLS handshake failures (35), resets and truncated transfers (18/52/55/56) up to 4 calls, as base's `scripts/develop.sh` does. That makes at most 16 attempts, each with a connection phase (DNS, TCP and TLS) of at most 10s, so failing to connect costs at most about 200s with the backoff sleeps. diff --git a/src/cli-claude-code/devcontainer-feature.json b/src/cli-claude-code/devcontainer-feature.json index 1c424ae..b2f4871 100644 --- a/src/cli-claude-code/devcontainer-feature.json +++ b/src/cli-claude-code/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-claude-code", - "version": "1.0.0", + "version": "1.0.1", "name": "Claude Code", "description": "Installs Anthropic's native Claude Code binary (claude) at an exact version, checked against a sha256 you supply, with its auto-updater and manual updates turned off. No Node.js needed. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-claude-code", diff --git a/src/cli-claude-code/install-lib.sh b/src/cli-claude-code/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-claude-code/install-lib.sh +++ b/src/cli-claude-code/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-keycloak/devcontainer-feature.json b/src/cli-keycloak/devcontainer-feature.json index bda6665..319c59e 100644 --- a/src/cli-keycloak/devcontainer-feature.json +++ b/src/cli-keycloak/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-keycloak", - "version": "1.0.0", + "version": "1.0.1", "name": "Keycloak admin CLI (kcadm)", "description": "Installs a Keycloak admin CLI as kcadm: the official kcadm.sh (with a headless JRE) at an exact version, checked against a sha256 you supply, or a small curl wrapper around the Admin REST API. The two flavors share the name, not the syntax. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-keycloak", diff --git a/src/cli-keycloak/install-lib.sh b/src/cli-keycloak/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-keycloak/install-lib.sh +++ b/src/cli-keycloak/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-mosquitto/devcontainer-feature.json b/src/cli-mosquitto/devcontainer-feature.json index 3b12f6f..6604182 100644 --- a/src/cli-mosquitto/devcontainer-feature.json +++ b/src/cli-mosquitto/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-mosquitto", - "version": "1.0.0", + "version": "1.0.1", "name": "Mosquitto MQTT clients", "description": "Installs the Eclipse Mosquitto MQTT clients (mosquitto_pub, mosquitto_sub, mosquitto_rr) at an exact upstream version you choose, e.g. 2.0.22: on Debian from repo.mosquitto.org, whose signing key the feature pins by fingerprint, on Ubuntu from the distro's own archive. The versions available differ by distro. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-mosquitto", diff --git a/src/cli-mosquitto/install-lib.sh b/src/cli-mosquitto/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-mosquitto/install-lib.sh +++ b/src/cli-mosquitto/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-opencode/devcontainer-feature.json b/src/cli-opencode/devcontainer-feature.json index 7a3b006..f7fa34d 100644 --- a/src/cli-opencode/devcontainer-feature.json +++ b/src/cli-opencode/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-opencode", - "version": "1.0.0", + "version": "1.0.1", "name": "opencode", "description": "Installs the opencode AI coding agent (anomalyco/opencode) at an exact version, checked against a sha256 you supply, with its update checks turned off. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-opencode", diff --git a/src/cli-opencode/install-lib.sh b/src/cli-opencode/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-opencode/install-lib.sh +++ b/src/cli-opencode/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-postgres-client/devcontainer-feature.json b/src/cli-postgres-client/devcontainer-feature.json index 9a92f34..97263c7 100644 --- a/src/cli-postgres-client/devcontainer-feature.json +++ b/src/cli-postgres-client/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-postgres-client", - "version": "1.0.0", + "version": "1.0.1", "name": "PostgreSQL client (psql)", "description": "Installs the PostgreSQL client (psql, pg_dump, pg_restore) from the PostgreSQL apt repository (PGDG) at an exact upstream version you choose, e.g. 18.6. apt checks the packages against PGDG's signing key, which the feature pins by fingerprint. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-postgres-client", diff --git a/src/cli-postgres-client/install-lib.sh b/src/cli-postgres-client/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-postgres-client/install-lib.sh +++ b/src/cli-postgres-client/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-rustfs/devcontainer-feature.json b/src/cli-rustfs/devcontainer-feature.json index 3efce24..0b322fa 100644 --- a/src/cli-rustfs/devcontainer-feature.json +++ b/src/cli-rustfs/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-rustfs", - "version": "1.0.0", + "version": "1.0.1", "name": "RustFS CLI (rc)", "description": "Installs rc, RustFS's S3 client, from the upstream .deb at an exact version, checked against a sha256 you supply. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-rustfs", diff --git a/src/cli-rustfs/install-lib.sh b/src/cli-rustfs/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-rustfs/install-lib.sh +++ b/src/cli-rustfs/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-s5cmd/devcontainer-feature.json b/src/cli-s5cmd/devcontainer-feature.json index bff75a3..af06d05 100644 --- a/src/cli-s5cmd/devcontainer-feature.json +++ b/src/cli-s5cmd/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-s5cmd", - "version": "1.0.0", + "version": "1.0.1", "name": "s5cmd", "description": "Installs s5cmd, a fast S3 and local filesystem client, at an exact version, checked against a sha256 you supply. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-s5cmd", diff --git a/src/cli-s5cmd/install-lib.sh b/src/cli-s5cmd/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-s5cmd/install-lib.sh +++ b/src/cli-s5cmd/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/cli-valkey/devcontainer-feature.json b/src/cli-valkey/devcontainer-feature.json index dabc797..a6b10b1 100644 --- a/src/cli-valkey/devcontainer-feature.json +++ b/src/cli-valkey/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "cli-valkey", - "version": "1.0.0", + "version": "1.0.1", "name": "valkey-cli", "description": "Installs valkey-cli, the Valkey command-line client, from upstream's binary release at an exact version, checked against a sha256 you supply. There are no default pins.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/cli-valkey", diff --git a/src/cli-valkey/install-lib.sh b/src/cli-valkey/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/cli-valkey/install-lib.sh +++ b/src/cli-valkey/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" diff --git a/src/ssl-ca/devcontainer-feature.json b/src/ssl-ca/devcontainer-feature.json index 3e7bb72..7433bde 100644 --- a/src/ssl-ca/devcontainer-feature.json +++ b/src/ssl-ca/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "ssl-ca", - "version": "1.0.0", + "version": "1.0.1", "name": "Custom root CAs (ssl-ca)", "description": "Installs custom root CA certificates (inline PEM, URLs checked against a sha256 you supply, or *.crt files already in the image) into the system trust store and every JDK cacerts it finds, and points the usual per-tool CA variables at the system bundle. List it first in overrideFeatureInstallOrder.", "documentationURL": "https://github.com/craftainer/devcontainer-features/tree/main/src/ssl-ca", diff --git a/src/ssl-ca/install-lib.sh b/src/ssl-ca/install-lib.sh index 7ec1d49..96a61b6 100644 --- a/src/ssl-ca/install-lib.sh +++ b/src/ssl-ca/install-lib.sh @@ -335,8 +335,9 @@ _il_ensure_curl() { # including the connect timeout) and HTTP 408/429/5xx; with # --retry-connrefused also ECONNREFUSED, but not other connect errors # such as EHOSTUNREACH or ENETUNREACH. This loop retries what curl -# gives up on: DNS and connect failures (exit 6/7), resets and truncated -# transfers (18/52/55/56), as scripts/develop.sh's fetch does. +# gives up on: DNS and connect failures (exit 6/7), TLS handshake +# failures such as repo.mosquitto.org's "unexpected eof" (35), resets and +# truncated transfers (18/52/55/56), as scripts/develop.sh's fetch does. # Worst case: 4 curl calls of up to 4 attempts each, 16 attempts in # all. --connect-timeout 10 bounds each attempt's connection phase (DNS, # TCP and TLS) to 10s, so failing to connect costs at most about 200s @@ -354,7 +355,7 @@ _il_curl() { --retry-connrefused -o "$dest" "$url" || status=$? case "$status" in 0) return 0 ;; - 6 | 7 | 18 | 52 | 55 | 56) + 6 | 7 | 18 | 35 | 52 | 55 | 56) if [ "$call" -lt "$calls" ]; then echo "install-lib: curl exit ${status} (call ${call}/${calls}); retrying in $((call * 2))s: ${url}" >&2 sleep $((call * 2)) @@ -452,7 +453,7 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any \ + if ! apt-get update --error-on=any -o Acquire::Retries=3 \ -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" From fddec4a1c64037da0a72aba795530f33e4c799fd Mon Sep 17 00:00:00 2001 From: crazyracer98 <8631139+crazyracer98@users.noreply.github.com> Date: Fri, 13 Nov 2026 07:43:46 +0000 Subject: [PATCH 2/3] fix(install-lib): repeat a failed apt-get update of an added repository --- common/install-lib.sh | 21 ++++++++++++++++++--- src/cli-claude-code/install-lib.sh | 21 ++++++++++++++++++--- src/cli-keycloak/install-lib.sh | 21 ++++++++++++++++++--- src/cli-mosquitto/install-lib.sh | 21 ++++++++++++++++++--- src/cli-opencode/install-lib.sh | 21 ++++++++++++++++++--- src/cli-postgres-client/install-lib.sh | 21 ++++++++++++++++++--- src/cli-rustfs/install-lib.sh | 21 ++++++++++++++++++--- src/cli-s5cmd/install-lib.sh | 21 ++++++++++++++++++--- src/cli-valkey/install-lib.sh | 21 ++++++++++++++++++--- src/ssl-ca/install-lib.sh | 21 ++++++++++++++++++--- 10 files changed, 180 insertions(+), 30 deletions(-) diff --git a/common/install-lib.sh b/common/install-lib.sh index 96a61b6..25467b4 100644 --- a/common/install-lib.sh +++ b/common/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-claude-code/install-lib.sh b/src/cli-claude-code/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-claude-code/install-lib.sh +++ b/src/cli-claude-code/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-keycloak/install-lib.sh b/src/cli-keycloak/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-keycloak/install-lib.sh +++ b/src/cli-keycloak/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-mosquitto/install-lib.sh b/src/cli-mosquitto/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-mosquitto/install-lib.sh +++ b/src/cli-mosquitto/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-opencode/install-lib.sh b/src/cli-opencode/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-opencode/install-lib.sh +++ b/src/cli-opencode/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-postgres-client/install-lib.sh b/src/cli-postgres-client/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-postgres-client/install-lib.sh +++ b/src/cli-postgres-client/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-rustfs/install-lib.sh b/src/cli-rustfs/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-rustfs/install-lib.sh +++ b/src/cli-rustfs/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-s5cmd/install-lib.sh b/src/cli-s5cmd/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-s5cmd/install-lib.sh +++ b/src/cli-s5cmd/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/cli-valkey/install-lib.sh b/src/cli-valkey/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/cli-valkey/install-lib.sh +++ b/src/cli-valkey/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi diff --git a/src/ssl-ca/install-lib.sh b/src/ssl-ca/install-lib.sh index 96a61b6..25467b4 100644 --- a/src/ssl-ca/install-lib.sh +++ b/src/ssl-ca/install-lib.sh @@ -453,9 +453,24 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - if ! apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then + # A repository that resets some TLS handshakes (repo.mosquitto.org does, + # about one in three) fails even apt's own Acquire::Retries, which retry + # within seconds, so the whole update is also repeated with a pause. + local attempt=1 attempts=4 updated=0 + while [ "$attempt" -le "$attempts" ]; do + if apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then + updated=1 + break + fi + if [ "$attempt" -lt "$attempts" ]; then + echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + fi + attempt=$((attempt + 1)) + done + if [ "$updated" -ne 1 ]; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi From 56736f175568abfbd6e223edc63db822ef9a074e Mon Sep 17 00:00:00 2001 From: crazyracer98 <8631139+crazyracer98@users.noreply.github.com> Date: Fri, 13 Nov 2026 07:54:55 +0000 Subject: [PATCH 3/3] fix(install-lib): retry apt update and install with a pause (TLS resets from repo.mosquitto.org) --- common/install-lib.sh | 49 ++++++++++++++------------ src/cli-claude-code/install-lib.sh | 49 ++++++++++++++------------ src/cli-keycloak/install-lib.sh | 49 ++++++++++++++------------ src/cli-mosquitto/install-lib.sh | 49 ++++++++++++++------------ src/cli-opencode/install-lib.sh | 49 ++++++++++++++------------ src/cli-postgres-client/install-lib.sh | 49 ++++++++++++++------------ src/cli-rustfs/install-lib.sh | 49 ++++++++++++++------------ src/cli-s5cmd/install-lib.sh | 49 ++++++++++++++------------ src/cli-valkey/install-lib.sh | 49 ++++++++++++++------------ src/ssl-ca/install-lib.sh | 49 ++++++++++++++------------ 10 files changed, 270 insertions(+), 220 deletions(-) diff --git a/common/install-lib.sh b/common/install-lib.sh index 25467b4..c63dfd0 100644 --- a/common/install-lib.sh +++ b/common/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-claude-code/install-lib.sh b/src/cli-claude-code/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-claude-code/install-lib.sh +++ b/src/cli-claude-code/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-keycloak/install-lib.sh b/src/cli-keycloak/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-keycloak/install-lib.sh +++ b/src/cli-keycloak/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-mosquitto/install-lib.sh b/src/cli-mosquitto/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-mosquitto/install-lib.sh +++ b/src/cli-mosquitto/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-opencode/install-lib.sh b/src/cli-opencode/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-opencode/install-lib.sh +++ b/src/cli-opencode/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-postgres-client/install-lib.sh b/src/cli-postgres-client/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-postgres-client/install-lib.sh +++ b/src/cli-postgres-client/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-rustfs/install-lib.sh b/src/cli-rustfs/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-rustfs/install-lib.sh +++ b/src/cli-rustfs/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-s5cmd/install-lib.sh b/src/cli-s5cmd/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-s5cmd/install-lib.sh +++ b/src/cli-s5cmd/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/cli-valkey/install-lib.sh b/src/cli-valkey/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/cli-valkey/install-lib.sh +++ b/src/cli-valkey/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \ diff --git a/src/ssl-ca/install-lib.sh b/src/ssl-ca/install-lib.sh index 25467b4..c63dfd0 100644 --- a/src/ssl-ca/install-lib.sh +++ b/src/ssl-ca/install-lib.sh @@ -48,6 +48,26 @@ il_arch() { esac } +# _il_retry ...: runs the command, up to 4 times with +# a pause of 5s, 10s and 15s between tries; returns the last status. For +# the network steps of apt (update, a package download): a host that resets +# some TLS handshakes (repo.mosquitto.org does, about one in three) fails +# even apt's own Acquire::Retries, which retry within seconds. +_il_retry() { + local what="$1" attempt=1 attempts=4 status=0 + shift + while :; do + status=0 + "$@" || status=$? + if [ "$status" -eq 0 ] || [ "$attempt" -ge "$attempts" ]; then + return "$status" + fi + echo "install-lib: ${what} failed (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + attempt=$((attempt + 1)) + done +} + # il_apt_install ...: installs packages without recommends, then # removes the apt lists so they don't stay in the image layer. il_apt_install() { @@ -55,8 +75,8 @@ il_apt_install() { _il_die "il_apt_install: no packages given" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" - apt-get install -y --no-install-recommends "$@" \ + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "$@" \ || _il_die "apt-get install failed: $*" rm -rf /var/lib/apt/lists/* } @@ -453,24 +473,9 @@ il_apt_add_repo() { rm -rf "$tmp" echo "install-lib: added apt repository ${name} (key ${fpr})" export DEBIAN_FRONTEND=noninteractive - # A repository that resets some TLS handshakes (repo.mosquitto.org does, - # about one in three) fails even apt's own Acquire::Retries, which retry - # within seconds, so the whole update is also repeated with a pause. - local attempt=1 attempts=4 updated=0 - while [ "$attempt" -le "$attempts" ]; do - if apt-get update --error-on=any -o Acquire::Retries=3 \ - -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ - -o APT::Get::List-Cleanup=0; then - updated=1 - break - fi - if [ "$attempt" -lt "$attempts" ]; then - echo "install-lib: apt-get update failed for ${name} (attempt ${attempt}/${attempts}); retrying in $((attempt * 5))s" >&2 - sleep $((attempt * 5)) - fi - attempt=$((attempt + 1)) - done - if [ "$updated" -ne 1 ]; then + if ! _il_retry "apt-get update for ${name}" apt-get update --error-on=any -o Acquire::Retries=3 \ + -o Dir::Etc::SourceList="$list" -o Dir::Etc::SourceParts=- \ + -o APT::Get::List-Cleanup=0; then rm -f "$keyring" "$list" _il_die "apt-get update failed for the ${name} repository (${source_line}); removed ${keyring} and ${list}" fi @@ -544,7 +549,7 @@ il_apt_install_pinned() { "(digits and dots, e.g. 18.6; no leading v, no distro revision)" fi export DEBIAN_FRONTEND=noninteractive - apt-get update || _il_die "apt-get update failed" + _il_retry "apt-get update" apt-get update -o Acquire::Retries=3 || _il_die "apt-get update failed" # madison prints "pkg | version | source Packages" per version and # source; Sources lines (deb-src) are skipped. available="$(apt-cache madison "$pkg" \ @@ -597,7 +602,7 @@ il_apt_install_pinned() { fi done echo "install-lib: installing ${pkg}=${chosen} ${deps[*]}" - apt-get install -y --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ + _il_retry "apt-get install" apt-get install -y -o Acquire::Retries=3 --no-install-recommends "${pkg}=${chosen}" "${deps[@]}" \ || _il_die "apt-get install failed: ${pkg}=${chosen} ${deps[*]}" if [ "${#auto[@]}" -gt 0 ]; then apt-mark auto "${auto[@]}" >/dev/null \