Improve error feedback for build cache errors (#2473) We shouldn't fail the build when we can't package a task's outputs. We should also not fail the build when unpacking some already downloaded outputs.
If there was a failure during unpacking, we can expect the task's output files to be in a messed up state. If this happens, we explicitly clean all of the task's outputs, update the pre-execution output file snapshots, and force the task to execute in non-incremental mode.
This commit also removes the retry logic we had previously when "recoverable" errors were encountered while downloading or uploading cached results. Instead, all errors (except for the aforementioned failed unpacking cleanup errors) are recoverable, and we simply switch off the cache for the build after the first such error.
Store artifacts from the remote cache in the local cache When the default local directory build cache is used, we use an optimized way to store the downloaded artifact in the cache. Using a custom local cache, or with the local cache disabled, a temporary file will be used to store the downloaded artifact.
Packing is also separated from uploading to the remote cache. Again, when the default directory cache is used to store the cached artifact in the local cache before uploading it to the remote cache. With a custom local cache, or when a local cache is not enabled, task outputs will be stored in a temporary file before uploading.
Build operations are emitted separately for packing, unpacking, uploading and downloading the cache artifact.