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

[Broker] Change create topic return error to Status.BAD_REQUEST #12919

Conversation

congbobo184
Copy link
Contributor

@congbobo184 congbobo184 commented Nov 22, 2021

Motivation

When create transaction system topic, broker will return Status.CONFLICT, It does not conform to the wrong return semantics of the method. So change it to Status.BAD_REQUEST, when client receive Status.BAD_REQUEST, it will generic PulsarAdminException and error code is Status.BAD_REQUEST

Modifications

change the error code to Status.BAD_REQUEST when create transaction system topic.

Verifying this change

change test verify

@github-actions
Copy link

@congbobo184:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@congbobo184 congbobo184 added doc-not-needed Your PR changes do not impact docs cherry-picked/branch-2.9 Archived: 2.9 is end of life labels Nov 22, 2021
@github-actions
Copy link

@congbobo184:Thanks for providing doc info!

@codelipenghui codelipenghui added release/2.9.1 and removed cherry-picked/branch-2.9 Archived: 2.9 is end of life labels Nov 22, 2021
@@ -250,7 +250,7 @@ protected void validateAdminAndClientPermission() {
protected void validateCreateTopic(TopicName topicName) {
if (isTransactionInternalName(topicName)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The topic TRANSACTION_COORDINATOR_ASSIGN could be created by users, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@@ -250,7 +250,7 @@ protected void validateAdminAndClientPermission() {
protected void validateCreateTopic(TopicName topicName) {
if (isTransactionInternalName(topicName)) {
log.warn("Try to create a topic in the system topic format! {}", topicName);
throw new RestException(Status.CONFLICT, "Cannot create topic in system topic format!");
throw new RestException(Status.BAD_REQUEST, "Cannot create topic in system topic format!");
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we list the system topics here? Users could know which are system topics.

Comment on lines 3696 to +3697
if (e.getCause() instanceof NotAllowedException) {
throw new RestException(Status.CONFLICT, e.getCause());
throw new RestException(Status.BAD_REQUEST, 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.

Interesting, do we through NotAllowedException for pulsar().getBrokerService().getTopicIfExists()? @congbobo184 Could you please help check how to improve this part? From the method name, we only get the topic ref if the topic exists, but looks like it also create topics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@codelipenghui codelipenghui added this to the 2.10.0 milestone Nov 22, 2021
@@ -250,7 +250,7 @@ protected void validateAdminAndClientPermission() {
protected void validateCreateTopic(TopicName topicName) {
if (isTransactionInternalName(topicName)) {
log.warn("Try to create a topic in the system topic format! {}", topicName);
Copy link
Contributor

Choose a reason for hiding this comment

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

change the log.warn information to log.warn("Forbidden to create transaction internal topic: {}" topicName) maybe more clear.

Comment on lines 3696 to +3697
if (e.getCause() instanceof NotAllowedException) {
throw new RestException(Status.CONFLICT, e.getCause());
throw new RestException(Status.BAD_REQUEST, 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.

+1

@codelipenghui
Copy link
Contributor

@congbobo184 Could you please check the comments?

Copy link
Contributor

@gaoran10 gaoran10 left a comment

Choose a reason for hiding this comment

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

Lgtm

@codelipenghui codelipenghui merged commit 2262a5d into apache:master Jan 18, 2022
codelipenghui pushed a commit that referenced this pull request Jan 18, 2022
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Jan 18, 2022
@congbobo184 congbobo184 deleted the congbobo184_create_transaction_system_topic_error_code_change branch March 24, 2022 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.9.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants