From f21798474eb0ab65aab3db4fb76b0df12722f547 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Thu, 12 Dec 2019 10:31:53 +0100 Subject: [PATCH] Better Logging GCS Blobstore Mock (#50102) * 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 --- .../repositories/blobstore/BlobStoreRepository.java | 2 +- .../main/java/fixture/gcs/GoogleCloudStorageHttpHandler.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index 8333b9cf02976..fd7453aa38004 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -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); } })); } diff --git a/test/fixtures/gcs-fixture/src/main/java/fixture/gcs/GoogleCloudStorageHttpHandler.java b/test/fixtures/gcs-fixture/src/main/java/fixture/gcs/GoogleCloudStorageHttpHandler.java index 98b081a37e598..f0795968ff115 100644 --- a/test/fixtures/gcs-fixture/src/main/java/fixture/gcs/GoogleCloudStorageHttpHandler.java +++ b/test/fixtures/gcs-fixture/src/main/java/fixture/gcs/GoogleCloudStorageHttpHandler.java @@ -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)) {