Browse Source

KAFKA-15377: Don't expose externalized secret values in tasks-config API endpoint (#14244)

Reviewers: Greg Harris <greg.harris@aiven.io>
pull/14104/merge
Yash Mayya 1 year ago committed by GitHub
parent
commit
880288879e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java
  2. 2
      connect/runtime/src/main/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerder.java
  3. 7
      connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java
  4. 9
      connect/runtime/src/test/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerderTest.java

2
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/AbstractHerder.java

@ -311,7 +311,7 @@ public abstract class AbstractHerder implements Herder, TaskStatus.Listener, Con @@ -311,7 +311,7 @@ public abstract class AbstractHerder implements Herder, TaskStatus.Listener, Con
Map<ConnectorTaskId, Map<String, String>> configs = new HashMap<>();
for (ConnectorTaskId cti : configState.tasks(connector)) {
configs.put(cti, configState.taskConfig(cti));
configs.put(cti, configState.rawTaskConfig(cti));
}
return configs;

2
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerder.java

@ -579,7 +579,7 @@ public class StandaloneHerder extends AbstractHerder { @@ -579,7 +579,7 @@ public class StandaloneHerder extends AbstractHerder {
public void tasksConfig(String connName, Callback<Map<ConnectorTaskId, Map<String, String>>> callback) {
Map<ConnectorTaskId, Map<String, String>> tasksConfig = buildTasksConfig(connName);
if (tasksConfig.isEmpty()) {
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), tasksConfig);
callback.onCompletion(new NotFoundException("Connector " + connName + " not found"), null);
return;
}
callback.onCompletion(null, tasksConfig);

7
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/distributed/DistributedHerderTest.java

@ -2091,6 +2091,8 @@ public class DistributedHerderTest { @@ -2091,6 +2091,8 @@ public class DistributedHerderTest {
herder.connectorConfig(CONN1, connectorConfigCb);
FutureCallback<List<TaskInfo>> taskConfigsCb = new FutureCallback<>();
herder.taskConfigs(CONN1, taskConfigsCb);
FutureCallback<Map<ConnectorTaskId, Map<String, String>>> tasksConfigCb = new FutureCallback<>();
herder.tasksConfig(CONN1, tasksConfigCb);
herder.tick();
assertTrue(listConnectorsCb.isDone());
@ -2107,6 +2109,11 @@ public class DistributedHerderTest { @@ -2107,6 +2109,11 @@ public class DistributedHerderTest {
new TaskInfo(TASK1, TASK_CONFIG),
new TaskInfo(TASK2, TASK_CONFIG)),
taskConfigsCb.get());
Map<ConnectorTaskId, Map<String, String>> tasksConfig = new HashMap<>();
tasksConfig.put(TASK0, TASK_CONFIG);
tasksConfig.put(TASK1, TASK_CONFIG);
tasksConfig.put(TASK2, TASK_CONFIG);
assertEquals(tasksConfig, tasksConfigCb.get());
// Config transformation should not occur when requesting connector or task info
verify(configTransformer, never()).transform(eq(CONN1), any());

9
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/standalone/StandaloneHerderTest.java

@ -765,6 +765,7 @@ public class StandaloneHerderTest { @@ -765,6 +765,7 @@ public class StandaloneHerderTest {
Callback<ConnectorInfo> connectorInfoCb = PowerMock.createMock(Callback.class);
Callback<Map<String, String>> connectorConfigCb = PowerMock.createMock(Callback.class);
Callback<List<TaskInfo>> taskConfigsCb = PowerMock.createMock(Callback.class);
Callback<Map<ConnectorTaskId, Map<String, String>>> tasksConfigCb = PowerMock.createMock(Callback.class);
// Check accessors with empty worker
listConnectorsCb.onCompletion(null, Collections.EMPTY_SET);
@ -775,6 +776,8 @@ public class StandaloneHerderTest { @@ -775,6 +776,8 @@ public class StandaloneHerderTest {
EasyMock.expectLastCall();
taskConfigsCb.onCompletion(EasyMock.<NotFoundException>anyObject(), EasyMock.isNull());
EasyMock.expectLastCall();
tasksConfigCb.onCompletion(EasyMock.<NotFoundException>anyObject(), EasyMock.isNull());
EasyMock.expectLastCall();
// Create connector
connector = PowerMock.createMock(BogusSourceConnector.class);
@ -795,6 +798,10 @@ public class StandaloneHerderTest { @@ -795,6 +798,10 @@ public class StandaloneHerderTest {
taskConfigsCb.onCompletion(null, Arrays.asList(taskInfo));
EasyMock.expectLastCall();
Map<ConnectorTaskId, Map<String, String>> tasksConfig = Collections.singletonMap(new ConnectorTaskId(CONNECTOR_NAME, 0),
taskConfig(SourceSink.SOURCE));
tasksConfigCb.onCompletion(null, tasksConfig);
EasyMock.expectLastCall();
PowerMock.replayAll();
@ -803,6 +810,7 @@ public class StandaloneHerderTest { @@ -803,6 +810,7 @@ public class StandaloneHerderTest {
herder.connectorInfo(CONNECTOR_NAME, connectorInfoCb);
herder.connectorConfig(CONNECTOR_NAME, connectorConfigCb);
herder.taskConfigs(CONNECTOR_NAME, taskConfigsCb);
herder.tasksConfig(CONNECTOR_NAME, tasksConfigCb);
herder.putConnectorConfig(CONNECTOR_NAME, connConfig, false, createCallback);
Herder.Created<ConnectorInfo> connectorInfo = createCallback.get(1000L, TimeUnit.SECONDS);
@ -818,6 +826,7 @@ public class StandaloneHerderTest { @@ -818,6 +826,7 @@ public class StandaloneHerderTest {
herder.connectorInfo(CONNECTOR_NAME, connectorInfoCb);
herder.connectorConfig(CONNECTOR_NAME, connectorConfigCb);
herder.taskConfigs(CONNECTOR_NAME, taskConfigsCb);
herder.tasksConfig(CONNECTOR_NAME, tasksConfigCb);
PowerMock.verifyAll();
}

Loading…
Cancel
Save