Repository navigation
Conversation
jamesconwaydev
left a comment
There was a problem hiding this comment.
Thanks for this. It's a real pain to debug in CI when all you get is exit code 6. Read only, didn't run it. I traced both paths that reach the new messages on main's contrib/install.sh:
- Tarball and checksum (
execute, lines 59-60): these are plain calls, soset -eapplies. The newreturn "$rc"propagates out ofhttp_downloadand the script still exits with curl's code, as you say. A 404 used to exit 1 with nothing printed, becauselog_debugis hidden at the default_logp=6(line 144). Now it prints aterr. - Tag lookup (
github_releaseviahttp_copy, lines 299/309, called asREALTAG=$(github_release ...) && trueat line 79): hereset -eis suspended inside the function, so on main a curl failure fell through withcode=000and only "unable to find 'v0.76.1'" appeared. With this PR the failinggithub.com/.../releases/<tag>URL and curl's exit code also appear on stderr (log_errusesechoerr), so that path improves too. That's worth a line in the description.
One small suggestion: curl's -sL could become -sSL. -S keeps the progress meter off but still prints curl's own reason, e.g. curl: (6) Could not resolve host: get.trivy.dev, so users get the cause and not just the number. It's a one-character change in both branches, and it doesn't touch the -w '%{http_code}' output that gets captured into code.
|
@jamesconwaydev
Re-tested with |
jamesconwaydev
left a comment
There was a problem hiding this comment.
1e75e00 reads right to me (read only, I didn't run it). With -S curl's own reason lands on stderr, and since -w '%{http_code}' is the only thing on stdout, code stays clean.
I also followed the tag lookup, since it goes through the same function now. A tag that doesn't exist gets a 404 from github_release, so you'll see failed to download https://github.com/aquasecurity/trivy/releases/vX (HTTP status 404) and then the existing unable to find 'vX' line. That reads as useful context to me rather than noise, but it is a new line on that path, so worth a mention for the maintainers.
Description
contrib/install.shruns withset -e. Inhttp_download_curl, the assignmentcode=$(curl ...)exits the whole script as soon as curl itself fails(DNS failure, connection refused, blocked egress, ...), before the error
handling below it runs. Combined with
curl -s, users only see the exit codewith no URL or reason.
Users hit this during the recent
get.trivy.devDNS outage (#11533), whereCI logs only showed
Process completed with exit code 6. The same silentfailure happens in CI environments that restrict egress and do not allow
get.trivy.dev.This PR:
|| rc=$?and logs the failing URLand exit code with
log_errlog_errinstead oflog_debug(which is hidden by default)
-sSLinstead of-sL(e.g.
curl: (6) Could not resolve host: get.trivy.dev)github_release→http_copy): previously only"unable to find ''" was shown; now the failing
github.com/.../releases/<tag>URLand curl's exit code are reported as well
It does not change the download host or the download logic.
How to reproduce
Make
get.trivy.devunreachable inside a container:Before
After
Success path (unchanged)
Related issues
failure path. The related bug report is in discussion trivy.dev appears parked since Nov 3 21:34 UTC: get.trivy.dev is NXDOMAIN, breaking install.sh and setup-trivy #11533.
Checklist
contrib/install.sh. Verified manually with thereproduction above (dash and bash, curl and wget-only environments); shellcheck reports no warnings.