Better Logging GCS Blobstore Mock (#50102) (#50124)

* Better Logging GCS Blobstore Mock

Two things:
1. We should just throw a descriptive assertion error and figure out why we're not reading a multi-part instead of
returning a `400` and failing the tests that way here since we can't reproduce these 400s locally.
2. We were missing logging the exception on a cleanup delete failure that coincides with the `400` issue in tests.

Relates #49429
This commit is contained in:
Armin Braun 2019-12-12 11:17:22 +01:00 committed by GitHub
parent cbff63685a
commit 0fae4065ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -1193,7 +1193,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
try { try {
blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN); blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN);
} catch (IOException e) { } catch (IOException e) {
logger.warn("Failed to clean up old index blobs {}", oldIndexN); logger.warn(() -> new ParameterizedMessage("Failed to clean up old index blobs {}", oldIndexN), e);
} }
})); }));
} }

View File

@ -189,7 +189,8 @@ public class GoogleCloudStorageHttpHandler implements HttpHandler {
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length); exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length);
exchange.getResponseBody().write(response); exchange.getResponseBody().write(response);
} else { } else {
exchange.sendResponseHeaders(RestStatus.BAD_REQUEST.getStatus(), -1); throw new AssertionError("Could not read multi-part request to [" + request + "] with headers ["
+ new HashMap<>(exchange.getRequestHeaders()) + "]");
} }
} else if (Regex.simpleMatch("POST /upload/storage/v1/b/" + bucket + "/*uploadType=resumable*", request)) { } else if (Regex.simpleMatch("POST /upload/storage/v1/b/" + bucket + "/*uploadType=resumable*", request)) {