Skip to content

Commit

Permalink
Health report infrastructure doesn't trip the circuit breakers (elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidan authored Nov 2, 2023
1 parent 1f77422 commit 8485cd7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog/101629.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 101629
summary: Health report infrastructure doesn't trip the circuit breakers
area: Health
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
new RestChunkedToXContentListener<>(channel)
);
}

@Override
public boolean canTripCircuitBreaker() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected TransportHealthNodeAction(
Writeable.Reader<Response> response,
Executor executor
) {
super(actionName, true, transportService, actionFilters, request, EsExecutors.DIRECT_EXECUTOR_SERVICE);
super(actionName, false, transportService, actionFilters, request, EsExecutors.DIRECT_EXECUTOR_SERVICE);
this.transportService = transportService;
this.clusterService = clusterService;
this.threadPool = threadPool;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

package org.elasticsearch.health;

import org.elasticsearch.test.ESTestCase;

import static org.hamcrest.Matchers.is;

public class RestGetHealthActionTests extends ESTestCase {

public void testHealthReportAPIDoesNotTripCircuitBreakers() {
assertThat(new RestGetHealthAction().canTripCircuitBreaker(), is(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static org.elasticsearch.test.ClusterServiceUtils.setState;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;

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

if (healthOperationFailure) {
try {
Expand Down Expand Up @@ -283,6 +285,7 @@ public void testDelegateToHealthNodeWithoutParentTask() throws ExecutionExceptio

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

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

assertThat(transport.capturedRequests().length, equalTo(1));
CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0];
Expand All @@ -327,6 +331,8 @@ public void testHealthNodeOperationWithException() throws InterruptedException {
listener
);
assertTrue(listener.isDone());
assertThat(transportService.getRequestHandler("internal:testAction").canTripCircuitBreaker(), is(false));

try {
listener.get();
fail("A simulated RuntimeException should be thrown");
Expand Down

0 comments on commit 8485cd7

Please sign in to comment.