Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "status" API to DiagnosticContext, overhaul Downloads console output #1565

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

BillyONeal
Copy link
Member

@BillyONeal BillyONeal commented Jan 8, 2025

Todo (to undraft):

  • I want feedback on console output changes, see asset-caching.ps1 for examples.
  • Add more tests, particularly for multiple authoritative URLs case.
  • Dig around for other filed issues I fixed.

Extensive overhaul of our downloads handling and console output; @JavierMatosD and I have gone back and forth several times and yet kept introducing unintended bugs in other places, which led me to believe targeted fixes would no longer cut it.

Fixes many longstanding bugs and hopefully makes our console output for this more understandable:

  • We no longer print 'error' when an asset cache misses but the authoritative download succeeds. This partially undoes Editing asset cache output when using x-script #1541. It is good to print errors immediately when they happen, but if a subsequent authoritative download succeeds we need to not print those errors.
  • We now always and consistently print output from x-script s at the time that actually happens. Resolves https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2300063
  • We don't tell the user that proxy settings might fix a hash mismatch problem.
  • We do tell the user that proxy settings might fix a download from asset cache problem.
  • We now always tell the user the full command line we tried when invoking an x-script that fails.
  • We don't crash if an x-script doesn't create the file we expect, or creates a file with the wrong hash.
  • We now always print what we are doing before touching the network, so if we hang the user knows which server is being problematic. Note that this includes storing back to asset caches which we were previously entirely silent about except in case of failure.

Other changes:

  • Removed debug output about asset cache configuration. The output was misleading / wrong depending on readwrite settings, and echoing to the user exactly what they said before we've interpreted it is not useful debug output. (Contrast with other VcpkgPaths debug output which tend to be paths we have likely changed from something a user said)

Other notes:

  • This makes all dependencies of Binary cache: async push_success #908 speak DiagnosticContext so it will be easy to audit that the foreground/background thread behavior is correct after this.
  • I did test the curl status parsing on old Ubuntu again.

Special thanks to @JavierMatosD for his help in review of the first console output attempts and for blowing the dust off this area in the first place.

…or information, and change all MessageSink interaction to be line-oriented.

More than one line can be printed at a time, but there must be a line *between* messages.
…on rather than saying there was a download failure when no download was attempted.
Fixes many longstanding bugs and hopefully makes our console output for this more understandable:
* We no longer print 'error' when an asset cache misses but the authoritative download succeeds.
* We now always and consistently print output from x-script s at the time that actually happens. Resolves https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2300063
* We don't tell the user that proxy settings might fix a hash mismatch problem.
* We do the the user that proxy settings might fix a download from asset cache problem.
* We now always tell the user the full command line we tried when invoking an x-script that fails.
* We don't crash if an x-script doesn't create the file we expect, or creates a file with the wrong hash.
* We now always print what we are doing *before* touching the network, so if we hang the user knows which server is being problematic. Note that this includes storing back to asset caches which we were previously entirely silent about except in case of failure.

Other changes:
* Removed debug output about asset cache configuration. The output was misleading / wrong depending on readwrite settings, and echoing to the user exactly what they said before we've interpreted it is not useful debug output. (Contrast with other VcpkgPaths debug output which tend to be paths we have likely changed from something a user said)
Copy link
Contributor

@JavierMatosD JavierMatosD left a comment

Choose a reason for hiding this comment

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

Partial Review: I just reviewed the output based on the end to end tests. What happens in a sha mismatch scenario with x-block-origin enabled?

"Asset cache hit for .*; downloaded from: .*"
"A suitable version of cmake was not found \(required v[0-9\.]+\)\.",
"Trying to download cmake-[0-9.]+-[^.]+\.(zip|tar\.gz) using asset cache file://$assetCacheRegex/[0-9a-z]+",
"Download successful! Asset cache hit, did not try authoritative source https://github\.com/Kitware/CMake/releases/download/[^ ]+"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Download successful! Asset cache hit, did not try authoritative source https://github\.com/Kitware/CMake/releases/download/[^ ]+"
Asset cache hit!

I think that "Asset cache hit!" implies successful download which implies not trying the authoritative source. The previous line says we are engaging with asset cache so I don't think we need to say we didn't try the authoritative source.

Copy link
Member Author

Choose a reason for hiding this comment

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

The original intended URI needs to be in the output somehow. Where do you want it go instead?

#azurl (no), x-block-origin (no), asset-cache (n/a), download (sha-mismatch)
#Expected: Download message with the "you might need to configure a proxy" message and with expected/actual sha
Refresh-TestRoot
$expected = @(
"Downloading https://example\.com -> example3\.html",
"[^\n]+example3\.html\.\d+\.part: error: download from https://example\.com had an unexpected hash",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want the error:?

Suggested change
"[^\n]+example3\.html\.\d+\.part: error: download from https://example\.com had an unexpected hash",
"[^\n]+example3\.html\.\d+\.part: warning: download from https://example\.com had an unexpected hash",

Copy link
Member Author

Choose a reason for hiding this comment

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

It's fatal and we can't continue after it happens, so I think it needs to be error?

Remove-Item "$downloadsRoot/example3.html"
$expected = @(
"Trying to download example3\.html using asset cache file://$assetCacheRegex/[0-9a-z]+",
"Download successful! Asset cache hit, did not try authoritative source https://example\.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as previous comment. I will add that in the opposite , Asset cache miss', scenario we simply say "Asset cache miss; trying authoritative source".

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you saying you want to remove Download successful!?

include/vcpkg/base/fwd/downloads.h Outdated Show resolved Hide resolved
include/vcpkg/base/hash.h Outdated Show resolved Hide resolved
include/vcpkg/base/system.process.h Show resolved Hide resolved
src/vcpkg/binarycaching.cpp Show resolved Hide resolved
src/vcpkg/base/downloads.cpp Outdated Show resolved Hide resolved
src/vcpkg/base/downloads.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants