Skip to content

Storage retries - #1585

Merged
ttaylorr merged 6 commits into
masterfrom
storage-retries
Oct 17, 2016
Merged

ttaylorr merged 6 commits into
masterfrom
storage-retries

Conversation

@ttaylorr

Copy link
Copy Markdown
Contributor

This pull-request adds tests asserting retry behavior when both upload and download requests are made to the storage endpoint.

I will follow this PR up with another special-case handler guarding interactions with the batch API endpoint, which, once merged, will fully cover the new retry behavior at the integration level.

/cc @technoweenie @sschuberth

@technoweenie technoweenie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why this needs another approval...

@ttaylorr

Copy link
Copy Markdown
Contributor Author

Only reviews from users with write-access count towards the decision.

On Monday, October 17, 2016, risk danger olson [email protected]
wrote:

@technoweenie approved this pull request.

Not sure why this needs another approval...

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1585 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAbDbSlFob-AIBGmDDIl04lO_CLBci42ks5q04KBgaJpZM4KX1KA
.

Thanks,
Taylor

@ttaylorr
ttaylorr merged commit 76ad7e8 into master Oct 17, 2016
@ttaylorr
ttaylorr deleted the storage-retries branch October 17, 2016 15:18
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Feb 26, 2026
In our "lfstest-gitserver" test utility program, the storageHandler()
function is used to generate responses to HTTP requests which upload
or download individual Git LFS objects.  For both types of requests,
if the content of an object matches a specific "magic" string value
then the function simulates a set of conditions relevant for the
current shell test by returning a particular status code or checking
for a particular request header.

When handling a PUT object upload request, the object's SHA-256 hash
value as provided by the Git LFS client in the URL path is used to
determine whether the object content matches a given special or "magic"
key value.  For these types of requests, the storageHandler() function
first looks for an entry in the global oidHandlers map using the provided
OID as the key.  If an entry exists, its value is then checked against a
series of keys, and if a match is found, the PUT upload handler simulates
the relevant test conditions.

By contrast, when handling a GET object download request, the same
storageHandler() function does not refer to the oidHandlers map.
Instead, if it finds a stored object matching the OID provided by the
client, it then tries to match the object's content against each of a
series of special key strings.  Each match check is made by comparing
the length of the string and the length of the byte array containing
the object content, and then if those are equal, comparing the contents
of the string and the byte array.

This technique was first introduced to the object download handling
logic in commit c9c457c of PR git-lfs#1297
and then copied every time another special object content key was added
in later commits and PRs.

While functional, the discrepancy between the object upload and download
handling portions of the storageHandler() function somewhat obscures the
similarities between the two code segments, and has also led to some
confusion as to which special object content keys need to be defined in
the global contentHandlers array, from which the oidHandlers map is
populated.

For instance, in commit 864beb8 of
PR git-lfs#1585 the "storage-download-retry" string was added to the
contentHandlers array, but the corresponding entry in the oidHandlers
array is never utilized.

As we expect to update and correct some of the specialized handling
of object download test conditions in subsequent commits in this PR,
we first revise the storageHandler() function so that it mirrors the
design of the object upload handling section.  When responding to a
GET request, the function now checks for an entry in the oidHandlers
map, and if an entry is found, then uses its value in a "switch"
statement to search for a match against a specific string.

To make this change successful, we also need to register several
additional special object content keys in the contentHandlers array,
specifically the "status-batch-retry", "storage-download-retry-later",
and "storage-download-retry-later-no-header" strings.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Feb 26, 2026
In PR git-lfs#1585 we added tests to our shell test suite to verify that the
Git LFS client will retry object upload and download transfer requests
when one or more initial requests fail due to HTTP errors.  We placed
these tests in a shell script named "t/t-batch-retries.sh".

Then in PR git-lfs#3449 we updated the Git LFS client to respect HTTP responses
with 429 status codes and optional Retry-After headers by delaying its
subsequent retries, but we only implemented this change for individual
object upload and download requests and not for requests to the Batch API
endpoint itself.  This PR included several new shell tests, which we
placed in a script named "t/t-batch-retries-ratelimit.sh".

Later, in PR git-lfs#4573, we revised the client to also respect Batch API
responses with 429 status codes and optional Retry-After headers, and
added an appropriate set of tests to the "t/t-batch-retries-ratelimit.sh"
script, but only after moving the existing tests in that script into
a new file named "t/t-batch-storage-retries-ratelimit.sh".  As we
noted in commit 32f571d when we
made these changes:

  This commit ... moves the existing storage API endpoint tests ...
  for the same scenario to a more logical
  `t-batch-storage-retries-ratelimit.sh` file to not cause confusion
  with the actual batch API endpoint tests.

Following the same rationale, we now rename the "t/t-batch-retries.sh"
script to "t/t-batch-storage-retries.sh", since the tests it contains
exercise the client's retry logic for object upload and download
HTTP requests and not the retry logic for Batch API requests.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Mar 1, 2026
In our "lfstest-gitserver" test utility program, the storageHandler()
function is used to generate responses to HTTP requests which upload
or download individual Git LFS objects.  For both types of requests,
if the content of an object matches a specific "magic" string value
then the function simulates a set of conditions relevant for the
current shell test by returning a particular status code or checking
for a particular request header.

When handling a PUT object upload request, the object's SHA-256 hash
value as provided by the Git LFS client in the URL path is used to
determine whether the object content matches a given special or "magic"
key value.  For these types of requests, the storageHandler() function
first looks for an entry in the global oidHandlers map using the provided
OID as the key.  If an entry exists, its value is then checked against a
series of keys, and if a match is found, the PUT upload handler simulates
the relevant test conditions.

By contrast, when handling a GET object download request, the same
storageHandler() function does not refer to the oidHandlers map.
Instead, if it finds a stored object matching the OID provided by the
client, it then tries to match the object's content against each of a
series of special key strings.  Each match check is made by comparing
the length of the string and the length of the byte array containing
the object content, and then if those are equal, comparing the contents
of the string and the byte array.

This technique was first introduced to the object download handling
logic in commit c9c457c of PR git-lfs#1297
and then copied every time another special object content key was added
in later commits and PRs.

While functional, the discrepancy between the object upload and download
handling portions of the storageHandler() function somewhat obscures the
similarities between the two code segments, and has also led to some
confusion as to which special object content keys need to be defined in
the global contentHandlers array, from which the oidHandlers map is
populated.

For instance, in commit 864beb8 of
PR git-lfs#1585 the "storage-download-retry" string was added to the
contentHandlers array, but the corresponding entry in the oidHandlers
array is never utilized.

As we expect to update and correct some of the specialized handling
of object download test conditions in subsequent commits in this PR,
we first revise the storageHandler() function so that it mirrors the
design of the object upload handling section.  When responding to a
GET request, the function now checks for an entry in the oidHandlers
map, and if an entry is found, then uses its value in a "switch"
statement to search for a match against a specific string.

To make this change successful, we also need to register several
additional special object content keys in the contentHandlers array,
specifically the "status-batch-retry", "storage-download-retry-later",
and "storage-download-retry-later-no-header" strings.
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Mar 1, 2026
In PR git-lfs#1585 we added tests to our shell test suite to verify that the
Git LFS client will retry object upload and download transfer requests
when one or more initial requests fail due to HTTP errors.  We placed
these tests in a shell script named "t/t-batch-retries.sh".

Then in PR git-lfs#3449 we updated the Git LFS client to respect HTTP responses
with 429 status codes and optional Retry-After headers by delaying its
subsequent retries, but we only implemented this change for individual
object upload and download requests and not for requests to the Batch API
endpoint itself.  This PR included several new shell tests, which we
placed in a script named "t/t-batch-retries-ratelimit.sh".

Later, in PR git-lfs#4573, we revised the client to also respect Batch API
responses with 429 status codes and optional Retry-After headers, and
added an appropriate set of tests to the "t/t-batch-retries-ratelimit.sh"
script, but only after moving the existing tests in that script into
a new file named "t/t-batch-storage-retries-ratelimit.sh".  As we
noted in commit 32f571d when we
made these changes:

  This commit ... moves the existing storage API endpoint tests ...
  for the same scenario to a more logical
  `t-batch-storage-retries-ratelimit.sh` file to not cause confusion
  with the actual batch API endpoint tests.

Following the same rationale, we now rename the "t/t-batch-retries.sh"
script to "t/t-batch-storage-retries.sh", since the tests it contains
exercise the client's retry logic for object upload and download
HTTP requests and not the retry logic for Batch API requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants