Skip to content

Commit fcbbe9e

Browse files
authored
fix(build-container-bake): retry the Syft download once (#374)
Addresses the first half of #373. ## Why `anchore/sbom-action` downloads Syft at run time. That download failed twice in one evening on `netresearch/typo3-demo`: | time (UTC) | run | |---|---| | 17:27 | [31622180041](https://github.com/netresearch/typo3-demo/actions/runs/31622180041) | | 19:32 | [31633121104](https://github.com/netresearch/typo3-demo/actions/runs/31633121104) | Both recovered on a plain re-run with no repository change, and other builds of nearly the same image passed in between — so it is the download, not the image. Each failure cost a deployment. The SBOM job failing skips `validate`, and the consuming repo's Deploy workflow triggers on `workflow_run` of Build with `conclusion == 'success'`. Both times the container itself had already built successfully; only the inventory of it was missing. The same evening produced two more installer failures in unrelated jobs on that repo (Opengrep, betterleaks — both at their install step, both green on re-run), which is why #373 reads this as GitHub release downloads being unreliable rather than anything specific to this workflow. ## What this changes The first attempt gets `continue-on-error: true` and an `id`; a second, identical step runs only `if: steps.syft.outcome == 'failure'`. Chosen over a retry action because there is nothing new to pin and audit, and because the second attempt appears as its own step in the run rather than disappearing into a wrapper's output. | case | behaviour | |---|---| | first attempt succeeds | second is skipped | | first fails, second succeeds | job continues, SBOM present | | both fail | **job fails** — the second step has no `continue-on-error` | ## What this does not change Whether a missing SBOM should be allowed to stop a release. That is the second option in #373 and a supply-chain policy question, not mine to decide — the coupling stays exactly as it is. ## Verification Structural: the step order and the `if` guard are as listed above, and the file parses. I have not induced a Syft download failure to watch the retry fire; the behaviour rests on the documented semantics of `continue-on-error` and `steps.<id>.outcome`, which distinguish outcome from conclusion precisely for this pattern.
2 parents a5dcf03 + 7c46750 commit fcbbe9e

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

.github/workflows/build-container-bake.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,19 @@ jobs:
766766
--output-file="${RUNNER_TEMP}/sbom/sbom-app.cdx.json")
767767
echo "present=true" >> "$GITHUB_OUTPUT"
768768
769+
# Two attempts, because the action downloads Syft at run time and that
770+
# download is not reliable. It failed twice in one evening on
771+
# netresearch/typo3-demo, and each failure cost a deployment: this job
772+
# failing skips `validate`, and Deploy triggers on the Build workflow
773+
# concluding success. The container itself had built fine both times —
774+
# only the inventory of it was missing.
775+
#
776+
# continue-on-error plus a guarded repeat rather than a retry action: no
777+
# new dependency to pin and audit, and the second attempt is visible as
778+
# its own step in the run.
769779
- name: Generate scanned image SBOM (Syft)
780+
id: syft
781+
continue-on-error: true
770782
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
771783
env:
772784
# No file cataloguing. Syft's default emits one component per file
@@ -787,6 +799,32 @@ jobs:
787799
output-file: ${{ runner.temp }}/sbom/sbom-image.cdx.json
788800
upload-artifact: false
789801

802+
- name: Wait before the second Syft attempt
803+
if: steps.syft.outcome == 'failure'
804+
# The failure being retried is an HTTP 503 from github.com, which
805+
# routinely lasts longer than the seconds a bare repeat would wait —
806+
# both attempts would then land inside the same blip and the deployment
807+
# is lost anyway. cosign_retry further down uses 15/30/45s for the same
808+
# reason; one wait is enough here because a second failure is rare
809+
# enough to be worth a human look.
810+
run: sleep 30
811+
812+
- name: Generate scanned image SBOM (Syft, second attempt)
813+
if: steps.syft.outcome == 'failure'
814+
# Keep env and with identical to the first attempt. Dropping
815+
# SYFT_FILE_METADATA_SELECTION here would produce the per-file BOM the
816+
# comment above exists to prevent, and only on the rare retry path.
817+
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
818+
env:
819+
SYFT_FILE_METADATA_SELECTION: none
820+
with:
821+
image: ${{ matrix.subject.name }}@${{ matrix.subject.digest }}
822+
registry-username: ${{ github.actor }}
823+
registry-password: ${{ secrets.GITHUB_TOKEN }}
824+
format: cyclonedx-json
825+
output-file: ${{ runner.temp }}/sbom/sbom-image.cdx.json
826+
upload-artifact: false
827+
790828
- name: Merge SBOMs, set OCI subject, validate (cyclonedx-cli)
791829
env:
792830
# cyclonedx-cli publishes no checksum file; sha256 recorded at pin

0 commit comments

Comments
 (0)