diff --git a/README.md b/README.md index e94e275..20b2e7a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,18 @@ reference the Azure mirror directly are not changed. Set `enable_workaround_azure_mirror: 'false'` in the step's `with:` block to disable the workaround. +## CirrOS prefetch + +By default, the action downloads the CirrOS `uec.tar.gz` and `disk.img` images +from GitHub Releases into `devstack/files/` before running devstack. Devstack +skips its own download when the file is already there. This avoids timeouts +from `download.cirros-cloud.net`, which the Ironic devstack plugin hardcodes. +The version comes from `CIRROS_VERSION` in `conf_overrides`, or from devstack's +`stackrc`. A failed download only logs a warning, and devstack then downloads +the image itself. + +Set `prefetch_cirros: 'false'` in the step's `with:` block to disable it. + ## Usage Example of Github Action step: diff --git a/action.yaml b/action.yaml index b0dd244..ca6e2bb 100644 --- a/action.yaml +++ b/action.yaml @@ -22,6 +22,9 @@ inputs: force: description: 'Allow running devstack on unsupported distro' default: 'no' + prefetch_cirros: + description: 'Download the CirrOS images from GitHub Releases before running devstack' + default: 'true' runs: using: "composite" steps: @@ -98,6 +101,32 @@ runs: EOF_CONF_OVERRIDES working-directory: ./devstack shell: bash + - name: Prefetch CirrOS images + if: ${{ inputs.prefetch_cirros == 'true' }} + run: | + # The Ironic devstack plugin hardcodes http://download.cirros-cloud.net, + # which often times out from GitHub runners. Devstack skips its own + # download when the file is already in files/. + conf_value() { sed -nE "s/^$1=\"?([^\"]+)\"?\$/\1/p" local.conf | tail -1; } + version=$(conf_value CIRROS_VERSION) + version=${version:-$(sed -nE 's/^CIRROS_VERSION=\$\{CIRROS_VERSION:-"?([^"}]+)"?\}.*/\1/p' stackrc)} + arch=$(conf_value CIRROS_ARCH) + arch=${arch:-$(uname -m)} + mkdir -p files + for name in "cirros-${version}-${arch}-uec.tar.gz" "cirros-${version}-${arch}-disk.img"; do + [[ -s "files/${name}" ]] && continue + # Download to a temporary name so devstack never sees a partial file. + if curl -fsSL --retry 5 --retry-all-errors --connect-timeout 30 \ + -o "files/${name}.tmp" \ + "https://github.com/cirros-dev/cirros/releases/download/${version}/${name}"; then + mv "files/${name}.tmp" "files/${name}" + else + rm -f "files/${name}.tmp" + echo "::warning::Could not prefetch ${name}; devstack will download it itself." + fi + done + working-directory: ./devstack + shell: bash - name: Dump local.conf run: | cat local.conf