aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/core/platform/cloud/curl_http_request.cc8
-rw-r--r--tensorflow/core/platform/cloud/gcs_file_system_test.cc33
2 files changed, 29 insertions, 12 deletions
diff --git a/tensorflow/core/platform/cloud/curl_http_request.cc b/tensorflow/core/platform/cloud/curl_http_request.cc
index 88a5d1e96d..4b5f6974c1 100644
--- a/tensorflow/core/platform/cloud/curl_http_request.cc
+++ b/tensorflow/core/platform/cloud/curl_http_request.cc
@@ -493,14 +493,18 @@ Status CurlHttpRequest::Send() {
case 303: // See Other
case 304: // Not Modified
case 307: // Temporary Redirect
- case 308: // Resume Incomplete
case 412: // Precondition Failed
case 413: // Payload Too Large
result = errors::FailedPrecondition(error_message);
break;
// UNAVAILABLE indicates a problem that can go away if the request
- // is just retried without any modification.
+ // is just retried without any modification. 308 return codes are intended
+ // for write requests that can be retried. See the documentation and the
+ // official library:
+ // https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload
+ // https://github.com/google/apitools/blob/master/apitools/base/py/transfer.py
+ case 308: // Resume Incomplete
case 409: // Conflict
case 429: // Too Many Requests
case 500: // Internal Server Error
diff --git a/tensorflow/core/platform/cloud/gcs_file_system_test.cc b/tensorflow/core/platform/cloud/gcs_file_system_test.cc
index d452074ce3..cd9fd3adea 100644
--- a/tensorflow/core/platform/cloud/gcs_file_system_test.cc
+++ b/tensorflow/core/platform/cloud/gcs_file_system_test.cc
@@ -393,7 +393,7 @@ TEST(GcsFileSystemTest, NewWritableFile_ResumeUploadSucceeds) {
"Timeouts: 5 1 10\n"
"Header Content-Range: bytes */17\n"
"Put: yes\n",
- "", errors::FailedPrecondition("308"), nullptr,
+ "", errors::Unavailable("308"), nullptr,
{{"Range", "0-10"}}, 308),
new FakeHttpRequest("Uri: https://custom/upload/location\n"
"Auth Token: fake_token\n"
@@ -406,13 +406,26 @@ TEST(GcsFileSystemTest, NewWritableFile_ResumeUploadSucceeds) {
"Timeouts: 5 1 10\n"
"Header Content-Range: bytes */17\n"
"Put: yes\n",
- "", errors::FailedPrecondition("308"), nullptr,
+ "", errors::Unavailable("308"), nullptr,
{{"Range", "bytes=0-12"}}, 308),
new FakeHttpRequest("Uri: https://custom/upload/location\n"
"Auth Token: fake_token\n"
"Header Content-Range: bytes 13-16/17\n"
"Timeouts: 5 1 30\n"
"Put body: ent2\n",
+ "", errors::Unavailable("308"), 308),
+ new FakeHttpRequest("Uri: https://custom/upload/location\n"
+ "Auth Token: fake_token\n"
+ "Timeouts: 5 1 10\n"
+ "Header Content-Range: bytes */17\n"
+ "Put: yes\n",
+ "", errors::Unavailable("308"), nullptr,
+ {{"Range", "bytes=0-14"}}, 308),
+ new FakeHttpRequest("Uri: https://custom/upload/location\n"
+ "Auth Token: fake_token\n"
+ "Header Content-Range: bytes 15-16/17\n"
+ "Timeouts: 5 1 30\n"
+ "Put body: t2\n",
"")});
GcsFileSystem fs(std::unique_ptr<AuthProvider>(new FakeAuthProvider),
std::unique_ptr<HttpRequest::Factory>(
@@ -521,14 +534,14 @@ TEST(GcsFileSystemTest, NewWritableFile_ResumeUploadAllAttemptsFail) {
"Put body: content1,content2\n",
"", errors::Unavailable("503"), 503)});
for (int i = 0; i < 10; i++) {
- requests.emplace_back(new FakeHttpRequest(
- "Uri: https://custom/upload/location\n"
- "Auth Token: fake_token\n"
- "Timeouts: 5 1 10\n"
- "Header Content-Range: bytes */17\n"
- "Put: yes\n",
- "", errors::FailedPrecondition("important HTTP error 308"), nullptr,
- {{"Range", "0-10"}}, 308));
+ requests.emplace_back(
+ new FakeHttpRequest("Uri: https://custom/upload/location\n"
+ "Auth Token: fake_token\n"
+ "Timeouts: 5 1 10\n"
+ "Header Content-Range: bytes */17\n"
+ "Put: yes\n",
+ "", errors::Unavailable("important HTTP error 308"),
+ nullptr, {{"Range", "0-10"}}, 308));
requests.emplace_back(new FakeHttpRequest(
"Uri: https://custom/upload/location\n"
"Auth Token: fake_token\n"