Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Connect's dynamic log level changes #9752

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public Future<List<ConnectorPlugin>> listConnectorPlugins(Reconciliation reconci
}

private Future<Void> updateConnectorLogger(Reconciliation reconciliation, String host, int port, String logger, String level) {
String path = "/admin/loggers/" + logger;
String path = "/admin/loggers/" + logger + "?scope=cluster";
JsonObject levelJO = new JsonObject();
levelJO.put("level", level);
LOGGER.debugCr(reconciliation, "Making PUT request to {} with body {}", path, levelJO);
Expand All @@ -405,7 +405,7 @@ private Future<Void> updateConnectorLogger(Reconciliation reconciliation, String
.write(buffer.toString());
request.result().send(response -> {
if (response.succeeded()) {
if (response.result().statusCode() == 200) {
if (List.of(200, 204).contains(response.result().statusCode())) {
response.result().bodyHandler(body -> {
LOGGER.debugCr(reconciliation, "Logger {} updated to level {}", logger, level);
result.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

public class ConnectCluster {
Expand Down Expand Up @@ -60,6 +61,7 @@ public void startup() throws InterruptedException {
try {
ConnectDistributed connectDistributed = new ConnectDistributed();
Connect connect = connectDistributed.startConnect(workerProps);
waitConnectRunning(connect);
connectInstances.add(connect);
connectPorts.add(port);
l.countDown();
Expand All @@ -81,6 +83,20 @@ public void startup() throws InterruptedException {
}
}

private static void waitConnectRunning(Connect connect) {
int counter = 30;
while (!connect.isRunning() && counter-- > 0) {
try {
TimeUnit.MILLISECONDS.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
if (!connect.isRunning()) {
throw new RuntimeException("Connect failed to start after 3 seconds.");
}
}

public void shutdown() {
for (Connect t : connectInstances) {
t.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public class KafkaConnectApiIT {

@BeforeEach
public void beforeEach() throws InterruptedException {
// Start a 3 node connect cluster
// Start a 1 node connect cluster
connectCluster = new ConnectCluster()
.usingBrokers(cluster.getBootstrapServers())
.addConnectNodes(3);
.addConnectNodes(1);
connectCluster.startup();
port = connectCluster.getPort(2);
port = connectCluster.getPort(0);
}

@AfterEach
Expand Down