Backport of [VAULT-5003] Use net/http client in Sys().RaftSnapshotRestore into release/1.10.x #14839
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.
Backport
This PR is auto-generated from #14269 to be assessed for backporting due to the inclusion of the label backport/1.10.x.
The below text is copied from the body of the original PR.
What does this PR do?
Modifies
(*client).Sys().RaftSnapshotRestore
function to use a net/http client to prevent attempting to read the entire body of a request (which is the case in our(*client).RawRequestWithContext()
)The
go-retryablehttp
package makes a copy of the request body on construction of a retry-able request to be able to re-play the request. When large snapshots are streamed to the server, this is problematic for the API client’sSys().RaftSnapshotRestore
function.Any useful background information?
This likely hasn't been identified as a problem in our CLI tool because we use files that
go-retryablehttp
can handle without reading the full value into memory.Our
(*client).Sys().RaftSnapshot
method currently implements a net/http client.How has this been tested?
Tests have been updated to use helper functions.
Analyzed a memory profile of our current code when writing a "large" snapshot, which copies the entire request body, where the new code does not. Large writes have not been included in the updated tests as to not gobble up unnecessary resources.
"large" data object: