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] [admin] Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication #19879

Merged

Conversation

poorbarcode
Copy link
Contributor

Motivation

As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.

2023-03-21T18:09:57,909 - INFO  - [pulsar-web-75-16:Slf4jRequestLogWriter@62] - 127.0.0.1 - - [21/3月/2023:18:09:57 +0800] "DELETE /admin/v2/persistent/pulsar/ns/tp_e82c0505-d47f-4e4a-8a62-9fa8d6341b76-d6d75112-fbe3-419d-a2d4-2186707185db?force=false&deleteSchema=true HTTP/1.1" 500 6641 "-" "Pulsar-Java-v3.0.0-SNAPSHOT" 11

In this case, we should give an error of 400 instead of 500.

Modifications

Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication

2023-03-21T18:13:10,840 - WARN  - [AsyncHttpClient-236-1:BaseResource$4@236] - [http://localhost:64881/admin/v2/persistent/pulsar/ns/tp_630d809a-6874-4c1b-99ad-5f5e0147950a-ed229063-2805-4ca6-abfb-b9685a4b93f3?force=false&deleteSchema=true] Failed to perform http delete request: javax.ws.rs.BadRequestException: HTTP 400 {"reason":"Delete forbidden topic is replicated on clusters [r2, r3]"}

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 21, 2023
@mattisonchao
Copy link
Member

I think 422 is better.

@poorbarcode
Copy link
Contributor Author

poorbarcode commented Mar 21, 2023

@mattisonchao

I think 422 is better.

Good idea. Already changed the response code to 422

@@ -1106,7 +1106,9 @@ public void deleteTopic(
ex = new RestException(Response.Status.PRECONDITION_FAILED,
t.getMessage());
}
if (isManagedLedgerNotFoundException(t)) {
if (t instanceof IllegalStateException){
Copy link
Member

Choose a reason for hiding this comment

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

IMO, the common exception IllegalStateException is not good here. we can't identify what happened here. maybe we can improve it in the future?

@mattisonchao
Copy link
Member

@poorbarcode Should we cherry-pick it to previous branches?

@poorbarcode
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@poorbarcode poorbarcode merged commit a903733 into apache:master Mar 22, 2023
40 of 41 checks passed
@poorbarcode poorbarcode deleted the fix/res_code_if_fail_by_replication branch March 22, 2023 08:49
poorbarcode added a commit that referenced this pull request Mar 22, 2023
…pic fails due to enabled geo-replication (#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
poorbarcode added a commit that referenced this pull request Mar 22, 2023
…pic fails due to enabled geo-replication (#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
poorbarcode added a commit that referenced this pull request Mar 22, 2023
…pic fails due to enabled geo-replication (#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
poorbarcode added a commit that referenced this pull request Mar 27, 2023
…elete topic fails due to enabled geo-replication (#19879)"

This reverts commit a24659a.
poorbarcode added a commit that referenced this pull request Mar 27, 2023
…pic fails due to enabled geo-replication (#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
poorbarcode added a commit that referenced this pull request Mar 27, 2023
…elete topic fails due to enabled geo-replication (#19879)"

This reverts commit 4e2105a.
poorbarcode added a commit that referenced this pull request Mar 27, 2023
…pic fails due to enabled geo-replication (#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Mar 29, 2023
…pic fails due to enabled geo-replication (apache#19879)

Motivation: As expected, If geo-replication is enabled, a topic cannot be deleted. However deleting that topic returns a 500, and no further info.
Modifications: Make response code to 400 instead of 500 when delete topic fails due to enabled geo-replication
(cherry picked from commit a903733)
(cherry picked from commit db6a59b)
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.

None yet

3 participants