Skip to content

Commit 0df72a3

Browse files
authored
Health report infrastructure doesn't trip the circuit breakers (#101629) (#101720)
1 parent 8f85e2e commit 0df72a3

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

docs/changelog/101629.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 101629
2+
summary: Health report infrastructure doesn't trip the circuit breakers
3+
area: Health
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/health/RestGetHealthAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,9 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
5151
new RestChunkedToXContentListener<>(channel)
5252
);
5353
}
54+
55+
@Override
56+
public boolean canTripCircuitBreaker() {
57+
return false;
58+
}
5459
}

server/src/main/java/org/elasticsearch/health/node/action/TransportHealthNodeAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected TransportHealthNodeAction(
7474
Writeable.Reader<Response> response,
7575
Executor executor
7676
) {
77-
super(actionName, true, transportService, actionFilters, request, EsExecutors.DIRECT_EXECUTOR_SERVICE);
77+
super(actionName, false, transportService, actionFilters, request, EsExecutors.DIRECT_EXECUTOR_SERVICE);
7878
this.transportService = transportService;
7979
this.clusterService = clusterService;
8080
this.threadPool = threadPool;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.health;
10+
11+
import org.elasticsearch.test.ESTestCase;
12+
13+
import static org.hamcrest.Matchers.is;
14+
15+
public class RestGetHealthActionTests extends ESTestCase {
16+
17+
public void testHealthReportAPIDoesNotTripCircuitBreakers() {
18+
assertThat(new RestGetHealthAction().canTripCircuitBreaker(), is(false));
19+
}
20+
}

server/src/test/java/org/elasticsearch/health/node/action/TransportHealthNodeActionTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import static org.elasticsearch.test.ClusterServiceUtils.setState;
5353
import static org.hamcrest.Matchers.equalTo;
5454
import static org.hamcrest.Matchers.instanceOf;
55+
import static org.hamcrest.Matchers.is;
5556

5657
public class TransportHealthNodeActionTests extends ESTestCase {
5758
private static ThreadPool threadPool;
@@ -250,6 +251,7 @@ protected void healthOperation(Task task, Request request, ClusterState state, A
250251
}
251252
}, null, request, listener);
252253
assertTrue(listener.isDone());
254+
assertThat(transportService.getRequestHandler("internal:testAction").canTripCircuitBreaker(), is(false));
253255

254256
if (healthOperationFailure) {
255257
try {
@@ -283,6 +285,7 @@ public void testDelegateToHealthNodeWithoutParentTask() throws ExecutionExceptio
283285

284286
PlainActionFuture<Response> listener = new PlainActionFuture<>();
285287
ActionTestUtils.execute(new Action("internal:testAction", transportService, clusterService, threadPool), null, request, listener);
288+
assertThat(transportService.getRequestHandler("internal:testAction").canTripCircuitBreaker(), is(false));
286289

287290
assertThat(transport.capturedRequests().length, equalTo(1));
288291
CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0];
@@ -303,6 +306,7 @@ public void testDelegateToHealthNodeWithParentTask() throws ExecutionException,
303306
PlainActionFuture<Response> listener = new PlainActionFuture<>();
304307
final CancellableTask task = (CancellableTask) taskManager.register("type", "internal:testAction", request);
305308
ActionTestUtils.execute(new Action("internal:testAction", transportService, clusterService, threadPool), task, request, listener);
309+
assertThat(transportService.getRequestHandler("internal:testAction").canTripCircuitBreaker(), is(false));
306310

307311
assertThat(transport.capturedRequests().length, equalTo(1));
308312
CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0];
@@ -327,6 +331,8 @@ public void testHealthNodeOperationWithException() throws InterruptedException {
327331
listener
328332
);
329333
assertTrue(listener.isDone());
334+
assertThat(transportService.getRequestHandler("internal:testAction").canTripCircuitBreaker(), is(false));
335+
330336
try {
331337
listener.get();
332338
fail("A simulated RuntimeException should be thrown");

0 commit comments

Comments
 (0)