Skip to content

Conversation

jack2012aa
Copy link

Description

Admin#desceibeReplicaLogDirs fails all futures when any error happens, regardless of the exception type or the failed directory. Especially, required by the issue, CLUSTER_AUTHORIZATION_FAILED should be handled independently.

Changes

Tests

Two tests are added: one for checking whether user can catch the CLUSTER_AUTHORIZATION_FAILED by getCause; one for checking whether failure in unrelated directory will affect other requests.

CLUSTER_AUTHORIZATION_FAILED

It is handled by an additional if statement now.

Single Directory-level Error

It is hard to map failed directories back to requested topic partition replica. If a directory or a broker fails, the response won't contain information of any replicas. The new attempt fails replicas that are not mentioned in healthy responses, if there is some error codes. It won't break the behavior of giving an empty result to unreplied replicas if no error code is in response.

@github-actions github-actions bot added triage PRs from the community clients labels Sep 2, 2025
Copy link
Contributor

@frankvicky frankvicky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jack2012aa: Thanks for the patch.
A few comments left.

}

if (!pendingPartitions.isEmpty() && !directoryFailures.isEmpty()) {
ArrayList<String> errorAtDir = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
ArrayList<String> errorAtDir = new ArrayList<>();
List<String> errorAtDir = new ArrayList<>();

Comment on lines 3153 to 3155
for (Map.Entry<String, Throwable> entry : directoryFailures.entrySet()) {
errorAtDir.add(entry.getValue().getClass().getName() + " at " + entry.getKey());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
for (Map.Entry<String, Throwable> entry : directoryFailures.entrySet()) {
errorAtDir.add(entry.getValue().getClass().getName() + " at " + entry.getKey());
}
directoryFailures.forEach((k, v) -> errorAtDir.add(v.getClass().getName() + " at " + k));

Comment on lines 2534 to 2535
Throwable e = assertThrows(Exception.class, () -> values.get(tpr).get());
assertInstanceOf(ClusterAuthorizationException.class, e.getCause());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use TestUtils#assertFutureThrows instead.

prepareDescribeLogDirsResponse(Errors.CLUSTER_AUTHORIZATION_FAILED, broker1log0),
env.cluster().nodeById(tpr.brokerId()));

DescribeReplicaLogDirsResult result = env.adminClient().describeReplicaLogDirs(singletonList(tpr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List.of

DescribeLogDirsResponseData.DescribeLogDirsResult failedResult = new DescribeLogDirsResponseData.DescribeLogDirsResult()
.setErrorCode(Errors.LOG_DIR_NOT_FOUND.code())
.setLogDir(broker1log1);
DescribeLogDirsResponse response = new DescribeLogDirsResponse(new DescribeLogDirsResponseData().setResults(asList(successfulResult, failedResult)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List.of

DescribeLogDirsResponse response = new DescribeLogDirsResponse(new DescribeLogDirsResponseData().setResults(asList(successfulResult, failedResult)));
env.kafkaClient().prepareResponseFrom(response, env.cluster().nodeById(successfulTpr.brokerId()));

DescribeReplicaLogDirsResult result = env.adminClient().describeReplicaLogDirs(asList(successfulTpr, failedTpr));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List.of

Map<TopicPartitionReplica, KafkaFuture<DescribeReplicaLogDirsResult.ReplicaLogDirInfo>> values = result.values();

assertNotNull(values.get(successfulTpr).get());
assertThrows(Exception.class, () -> values.get(failedTpr).get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should assert the class of this exception?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, an assertion on the exception type and could better ensure that the future ends with the expected reason. They are included in the new commit.

@github-actions github-actions bot removed the triage PRs from the community label Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants