From 1bb24a99c1572321367c3c556829ffc850376d83 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Thu, 15 Apr 2021 13:34:13 -0400 Subject: [PATCH] 35coreos-live/coreos-livepxe-rootfs: retry fetching rootfs forever We don't know how long it will take for networking to come up, so let's match Ignition's semantic of retrying to fetch remote resources forever. `curl` doesn't natively have support for this, so wrap it in a `while` loop. This also works around the fact that el8's `curl` doesn't support `--retry-all-errors`. This was previously added in #929. (cherry picked from commit d2776ed618d7d72fc0b226b7f08e45d3182406e7) --- .../35coreos-live/coreos-livepxe-rootfs.sh | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh index 0bc4e893bc..483587efa5 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-livepxe-rootfs.sh @@ -34,20 +34,24 @@ elif [[ -n "${rootfs_url}" ]]; then # First, reach out to the server to verify connectivity before # trying to download and pipe content through other programs. # Doing this allows us to retry all errors (including transient - # "no route to host" errors during startup), without using the - # --retry-all-errors, which is problematic (see curl man page) - # when piping the output. - curl_common_args="--silent --show-error --insecure --location --retry 5" - if ! curl --head --retry-all-errors $curl_common_args "${rootfs_url}" >/dev/null; then + # "no route to host" errors during startup). Note we can't use + # curl's --retry-all-errors here because it's not in el8's curl yet. + # We retry forever, matching Ignition's semantics. + curl_common_args="--silent --show-error --insecure --location" + while ! curl --head $curl_common_args "${rootfs_url}" >/dev/null; do echo "Couldn't establish connectivity with the server specified by coreos.live.rootfs_url=" >&2 - echo "Check that the URL is correct and can be reached." >&2 - exit 1 - fi + echo "Retrying in 5s..." >&2 + sleep 5 + done + # We don't need to verify TLS certificates because we're checking the # image hash. # bsdtar can read cpio archives and we already depend on it for # coreos-liveiso-persist-osmet.service, so use it instead of cpio. - if ! curl $curl_common_args "${rootfs_url}" | \ + # We shouldn't need a --retry here since we've just successfully HEADed the + # file, but let's add one just to be safe (e.g. if the connection just went + # online and flickers or something). + if ! curl $curl_common_args --retry 5 "${rootfs_url}" | \ rdcore stream-hash /etc/coreos-live-want-rootfs | \ bsdtar -xf - -C / ; then echo "Couldn't fetch, verify, and unpack image specified by coreos.live.rootfs_url=" >&2