Skip to content

KAFKA-15373: fix exception thrown in Admin#describeTopics for unknown ID#14599

Merged
jolshan merged 3 commits intoapache:trunkfrom
MikeEdgar:KAFKA-15373
Jan 4, 2024
Merged

KAFKA-15373: fix exception thrown in Admin#describeTopics for unknown ID#14599
jolshan merged 3 commits intoapache:trunkfrom
MikeEdgar:KAFKA-15373

Conversation

@MikeEdgar
Copy link
Copy Markdown
Contributor

Throw UnknownTopicIdException instead of InvalidTopicException when no name is found for the topic ID.

Similar to #6124 for describeTopics using a topic name. MockAdminClient already makes use of UnknownTopicIdException for this case.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ijuma ijuma requested a review from jolshan October 22, 2023 18:33
@MikeEdgar
Copy link
Copy Markdown
Contributor Author

MikeEdgar commented Nov 27, 2023

Hi @jolshan , please take a look at this PR to modify the exception thrown when describing a topic by an unknown topic ID. The CI failures don't appear related to the change.

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Dec 12, 2023

At first I was confused since the original PR had

assertThrows(classOf[ExecutionException], () => results.get(nonExistingTopicId).get).getCause.isInstanceOf[UnknownTopicIdException]

but on closer inspection (the debugger) I see that the future is actually InvalidTopicException and that this test is wrong.

I'm trying to think if there was any rationale for this decision, but after spending 20 minutes or so looking through my notes and old messages I couldn't find one.

The only other concern would be compatibility, but given that the unknown topic ID error is being returned by the server, but the Cluster API doesn't know how to handle it I think this change makes sense.

@ijuma do you have any concerns from the compatibility angle? Given this is an admin API, I don't think changing this error should break anything in a crazy way.

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Dec 12, 2023

I synced with @ijuma offline. I think it makes sense to return the UnknownTopicId exception since that is what we do for the deleteTopics api and what the server is using.

It is a bit annoying that we can't use the topicError directly and we convert to the cluster object that loses all the detail about the topic IDs and their error responses. But fixing that requires a larger refactor,

For now let's just fix

assertThrows(classOf[ExecutionException], () => results.get(nonExistingTopicId).get).getCause.isInstanceOf[UnknownTopicIdException]

@MikeEdgar
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @jolshan . If I'm following your comments on the broken test, the assertion

assertThrows(classOf[ExecutionException], () => results.get(nonExistingTopicId).get).getCause.isInstanceOf[UnknownTopicIdException] 

must be replaced with:

assertFutureExceptionTypeEquals(results.get(nonExistingTopicId), classOf[UnknownTopicIdException])

Correct?

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Dec 14, 2023

@MikeEdgar that looks to be right. But please run the test to make sure it works correctly.

@MikeEdgar
Copy link
Copy Markdown
Contributor Author

@jolshan , I've updated the test and it's passing, but the CI is failing on a seemingly unrelated test.

Gradle Test Run :storage:test > Gradle Test Executor 76 > TransactionsWithTieredStoreTest > testCommitTransactionTimeout(String) > testCommitTransactionTimeout(String).quorum=kraft FAILED

    org.apache.kafka.common.errors.TimeoutException: Timeout expired after 3000ms while awaiting InitProducerId

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Dec 21, 2023

Sorry for the delay @MikeEdgar. That is a known issue for the test. I will also look at this PR and run the build again.

@jolshan
Copy link
Copy Markdown
Member

jolshan commented Dec 22, 2023

Hey @MikeEdgar I'm seeing KafkaAdminClientTest.testDescribeTopicByIds failing due to it expecting the old error. Can we update that test?

Throw UnknownTopicIdException instead of InvalidTopicException

Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
Signed-off-by: Michael Edgar <medgar@redhat.com>
@jolshan
Copy link
Copy Markdown
Member

jolshan commented Jan 3, 2024

Thanks @MikeEdgar looks like the test is fixed. I'll run the build again to make sure there aren't any other related tests failing.

Copy link
Copy Markdown
Member

@jolshan jolshan left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@jolshan jolshan merged commit 105db82 into apache:trunk Jan 4, 2024
@MikeEdgar MikeEdgar deleted the KAFKA-15373 branch January 4, 2024 10:59
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
… ID (apache#14599)

Throw UnknownTopicIdException instead of InvalidTopicException when no name is found for the topic ID.

Similar to apache#6124 for describeTopics using a topic name. MockAdminClient already makes use of UnknownTopicIdException for this case.

Reviewers: Justine Olshan <jolshan@confluent.io>, Ashwin Pankaj <apankaj@confluent.io>
AnatolyPopov pushed a commit to aiven/kafka that referenced this pull request Feb 16, 2024
… ID (apache#14599)

Throw UnknownTopicIdException instead of InvalidTopicException when no name is found for the topic ID.

Similar to apache#6124 for describeTopics using a topic name. MockAdminClient already makes use of UnknownTopicIdException for this case.

Reviewers: Justine Olshan <jolshan@confluent.io>, Ashwin Pankaj <apankaj@confluent.io>
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
… ID (apache#14599)

Throw UnknownTopicIdException instead of InvalidTopicException when no name is found for the topic ID.

Similar to apache#6124 for describeTopics using a topic name. MockAdminClient already makes use of UnknownTopicIdException for this case.

Reviewers: Justine Olshan <jolshan@confluent.io>, Ashwin Pankaj <apankaj@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants