Skip to content

fix: upload_systest_dep.sh: ignore-content-length#10662

Merged
basvandijk merged 2 commits into
masterfrom
ai/deflake-sev_recovery-2026-07-06
Jul 7, 2026
Merged

fix: upload_systest_dep.sh: ignore-content-length#10662
basvandijk merged 2 commits into
masterfrom
ai/deflake-sev_recovery-2026-07-06

Conversation

@basvandijk

@basvandijk basvandijk commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

//rs/tests/nested:sev_recovery (and potentially any Farm-based systest) can
fail during setup with what looks like a bazel-remote connectivity error:

Found dep to upload ic-os/guestos/envs/sev-recovery-dev/disk-img.tar.zst (66d0…)
curl: (8) Invalid Content-Length: value
Failed to reach bazel-remote at 'http://server.bazel-remote.svc.cluster.local:8080/cas/66d0…'

Example run: https://github.com/dfinity/ic/actions/runs/28751952218/job/85252526147

Root cause

It is not a reachability problem. upload_systest_dep.sh's dep_in_cache()
probes bazel-remote with a HEAD request and reads only the HTTP status code:

code=$(curl --silent --show-error --max-time 30 -o /dev/null -w '%{http_code}' --head "$url")

bazel-remote's HEAD handler answers with, unconditionally:

ok, size := h.cache.Contains(r.Context(), kind, hash, -1)
...
w.Header().Set("Content-Length", strconv.FormatInt(size, 10))

Contains() returns "the size if known (or -1 if unknown)". A blob found in
the local disk cache always has a real size — which is why the two dev
images just above returned 200 (already uploaded). But on a local miss
Contains() falls through to the proxy/upstream backend, which can report a
blob as present but with unknown size (-1). The SEV-recovery disk image was
only in the proxy backend on that runner's cluster, so bazel-remote emitted the
literal header Content-Length: -1.

curl treats a negative Content-Length as a protocol violation and aborts with
exit code 8 (Invalid Content-Length: value) before printing %{http_code}.
The if ! code=$(curl …) branch then fires, the script prints
Failed to reach bazel-remote… and exits 1, failing the test setup. Because it
depends on whether the blob happens to be proxy-only vs. locally cached on a
given runner, the failure is intermittent.

Fix

Pass --ignore-content-length to the HEAD probe. curl then skips parsing the
bogus header and returns the real status code (200), so an already-cached dep
is correctly detected as uploaded instead of being misreported as an unreachable
server.

When a systest dependency (e.g. the SEV-recovery GuestOS disk image) is
present only in bazel-remote's proxy/upstream backend and not yet in the
local disk cache, bazel-remote answers the existence HEAD probe with an
invalid 'Content-Length: -1' header (its Contains() reports the size as
unknown). curl rejects that header with exit code 8 ('Invalid
Content-Length: value') before the script can read the HTTP status code,
so the already-cached dep is misreported as an unreachable bazel-remote
and the test setup fails (observed in //rs/tests/nested:sev_recovery).

Pass --ignore-content-length to the HEAD probe so curl skips parsing the
bogus header and returns the real status code (200), correctly detecting
the dep as already uploaded.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR deflakes Farm-based systest setup by making the bazel-remote cache probe robust to invalid Content-Length headers returned on HEAD responses when artifacts exist only in the proxy/upstream backend.

Changes:

  • Add --ignore-content-length to the curl --head probe in dep_in_cache() so curl still returns the HTTP status code even when bazel-remote responds with Content-Length: -1.
  • Document the underlying bazel-remote behavior and why the flag is required to avoid misclassifying cached artifacts as connectivity failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@basvandijk basvandijk marked this pull request as ready for review July 6, 2026 11:52
@basvandijk basvandijk requested a review from a team as a code owner July 6, 2026 11:52
@github-actions github-actions Bot added the @idx label Jul 6, 2026
@basvandijk basvandijk changed the title fix: deflake //rs/tests/nested:sev_recovery fix: upload_systest_dep.sh: ignore-content-length Jul 6, 2026
@basvandijk basvandijk merged commit e5c291d into master Jul 7, 2026
37 checks passed
@basvandijk basvandijk deleted the ai/deflake-sev_recovery-2026-07-06 branch July 7, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants