Skip to content

Commit

Permalink
Better Logging GCS Blobstore Mock (elastic#50102)
Browse files Browse the repository at this point in the history
* 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 elastic#49429
  • Loading branch information
original-brownbear committed Dec 12, 2019
1 parent cbff636 commit f217984
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
try {
blobContainer().deleteBlobsIgnoringIfNotExists(oldIndexN);
} 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);
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public void handle(final HttpExchange exchange) throws IOException {
exchange.sendResponseHeaders(RestStatus.OK.getStatus(), response.length);
exchange.getResponseBody().write(response);
} 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)) {
Expand Down

0 comments on commit f217984

Please sign in to comment.