Repository navigation
Skip remote content upload when the remote cache is read-only - #178
Merged
David Federman (dfederm) merged 3 commits intoAug 28, 2026
Conversation
CasCacheClient holds two sessions: the raw _remoteCacheSession and the _twoLevelCacheSession built from TwoLevelCacheConfiguration. When adding a node, content was uploaded directly through _remoteCacheSession without consulting RemoteCacheIsReadOnly, while the content hash list that would reference that content is published through _twoLevelCacheSession, which does honor it. The result is that a read-only client uploads content that can never be retrieved: no content hash list ever points at it, so no subsequent build can hit on it. The upload only costs egress, storage and build time, and leaves unreferenced blobs behind for lifecycle policies to collect. Guard the upload block on the read-only flag, which also elides the remote pin calls that were only made to decide what to upload. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
David Federman (dfederm)
requested changes
Aug 26, 2026
David Federman (dfederm)
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution!
Just 1 comment to add a regression test, but otherwise looks great!
Adds RecordingCacheSession / RecordingCache, minimal ICacheSession and ICache implementations that count the calls made against them, and two tests driving CasCacheClient.AddNodeInternalAsync: - AddNodeDoesNotUploadContentWhenRemoteCacheIsReadOnly asserts the remote session sees no PinAsync, PutStreamAsync or PutFileAsync calls, while the node metadata and content hash list are still written to the local cache. - AddNodeUploadsContentWhenRemoteCacheIsWritable asserts the remote session is still pinned and uploaded to when the remote cache is writable, so the guard is conditional rather than unconditional. The first test fails without the accompanying fix: Expected:<0>. Actual:<1>. 'actual' expression: 'remoteSession.PinCallCount'. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@microsoft-github-policy-service agree company="WiseTech Global" |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
David Federman (dfederm)
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RemoteCacheIsReadOnlysuppresses content hash list publication but not content upload, so a read-only client uploads content that no later build can ever retrieve — nothing references it. It costs egress, storage and build time for no benefit.CasCacheClientholds both the raw_remoteCacheSessionand the_twoLevelCacheSessionbuilt fromTwoLevelCacheConfiguration.AddNodeAsyncuploads content through the raw session without consulting the flag, while the content hash list goes through the two-level session, which honours it.Changes
RemoteCacheIsReadOnlyfrom the passedTwoLevelCacheConfigurationand skip the remote upload block when it is set. This also elides the remotePinBulkAsynccalls, which were made only to decide what to upload.Validation
dotnet build MSBuildCache.sln -c Release: succeeded, 0 warnings, 0 errorsdotnet test MSBuildCache.sln -c Release --no-build: 547/550 passed. The 3net472failures are a pre-existingThe tools version "Current" is unrecognizedenvironment issue inMSBuildCachePluginBaseTests; an unmodified checkout fails the same 3.No unit test added: there is no mock
ICacheSessioninCommon.Teststo build anAddNodeAsyncharness on, andCasCacheClientTestscurrently only covers the staticGetAddNodeResulthelper. Happy to add a mock session and a regression test if you'd like it in this PR.Fixes: #177