Skip to content

Commit

Permalink
feat(fetch-content): log x-cache-status when content size doesn't mat…
Browse files Browse the repository at this point in the history
…ch expected (#606)

Requested by SRE to help debug https://bugzilla.mozilla.org/show_bug.cgi?id=1932466
  • Loading branch information
bhearsum authored Nov 20, 2024
1 parent 8e7fc5a commit cf004d8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/taskgraph/run-task/fetch-content
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,13 @@ def stream_download(url, sha256=None, size=None, headers=None):
if size:
if size != content_length:
raise IntegrityError(
"size mismatch on %s: wanted %d; content-length is %d"
% (url, size, content_length)
"size mismatch on %s: wanted %d; content-length is %d, x-cache-status is: %s"
% (
url,
size,
content_length,
fh.getheader("x-cache-status"),
)
)
else:
size = content_length
Expand Down Expand Up @@ -435,7 +440,9 @@ def extract_archive(path, dest_dir):
log("%s extracted in %.3fs" % (path, time.time() - t0))


def should_repack_archive(orig: pathlib.Path, dest: pathlib.Path, strip_components=0, add_prefix="") -> bool:
def should_repack_archive(
orig: pathlib.Path, dest: pathlib.Path, strip_components=0, add_prefix=""
) -> bool:
"""
Determines whether we should attempt to repack an archive based on the naming conventions used
in the original file path, the destination file path, and any modifications such as stripping
Expand Down Expand Up @@ -573,7 +580,9 @@ def repack_archive(
ctx.copy_stream(ifh, fh)

else:
raise Exception(f"Attempt to repack an archive of unsupported type {orig_typ}")
raise Exception(
f"Attempt to repack an archive of unsupported type {orig_typ}"
)


def fetch_and_extract(url, dest_dir, extract=True, sha256=None, size=None):
Expand Down Expand Up @@ -660,8 +669,9 @@ def git_checkout_archive(
if re.match(r"^[a-fA-F0-9]{40}$", commit):
revision = commit
else:
ref_output = subprocess.check_output(["git", "ls-remote", repo,
'refs/heads/' + commit])
ref_output = subprocess.check_output(
["git", "ls-remote", repo, "refs/heads/" + commit]
)
revision, _ = ref_output.decode().split(maxsplit=1)
log("Fetching revision {}".format(revision))
return _git_checkout_github_archive(dest_path, repo, commit, prefix)
Expand Down

0 comments on commit cf004d8

Please sign in to comment.