You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "thetumbled (via GitHub)" <gi...@apache.org> on 2024/05/15 08:17:41 UTC

[PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

thetumbled opened a new pull request, #22715:
URL: https://github.com/apache/pulsar/pull/22715

   
   ### Motivation
   
   If the topic name is in the format of V1, we can subscribe a topic in non-existent cluster/namespace without any exception.
   
   ### Modifications
   
   Need to add check for such case.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "thetumbled (via GitHub)" <gi...@apache.org>.
thetumbled commented on code in PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#discussion_r1609166384


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -506,6 +507,18 @@ protected void validateClusterExists(String cluster) {
         }
     }
 
+    protected CompletableFuture<Void> validateNamespaceExists(NamespaceName namespace) {
+        try {
+            if (namespaceResources().namespaceExists(namespace)) {
+                return CompletableFuture.completedFuture(null);
+            } else {
+                return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND, "Namespace does not exist"));
+            }
+        } catch (Exception e) {
+            return FutureUtil.failedFuture(e);
+        }
+    }
+

Review Comment:
   <img width="798" alt="image" src="https://github.com/apache/pulsar/assets/52550727/f8fc4ded-9f21-47bc-8717-0c9fe44e0e47">
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#discussion_r1609159774


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -506,6 +507,18 @@ protected void validateClusterExists(String cluster) {
         }
     }
 
+    protected CompletableFuture<Void> validateNamespaceExists(NamespaceName namespace) {
+        try {
+            if (namespaceResources().namespaceExists(namespace)) {
+                return CompletableFuture.completedFuture(null);
+            } else {
+                return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND, "Namespace does not exist"));
+            }
+        } catch (Exception e) {
+            return FutureUtil.failedFuture(e);
+        }
+    }
+

Review Comment:
   Seems no need `try/catch`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "thomas-bousquet (via GitHub)" <gi...@apache.org>.
thomas-bousquet commented on code in PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#discussion_r2201670345


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -506,6 +507,18 @@ protected void validateClusterExists(String cluster) {
         }
     }
 
+    protected CompletableFuture<Void> validateNamespaceExists(NamespaceName namespace) {
+        try {
+            if (namespaceResources().namespaceExists(namespace)) {
+                return CompletableFuture.completedFuture(null);
+            } else {
+                return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND, "Namespace does not exist"));
+            }
+        } catch (Exception e) {
+            return FutureUtil.failedFuture(e);
+        }
+    }
+

Review Comment:
   Is it possible the same issue is present when the tenant does not exist?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "thetumbled (via GitHub)" <gi...@apache.org>.
thetumbled commented on PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#issuecomment-2117074263

   PTAL, thanks. @lhotari @dao-jun @BewareMyPower @poorbarcode 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat commented on PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#issuecomment-6352727161

   Thanks @thetumbled, and sorry this sat so long. The root cause was that `checkLocalOrGetPeerReplicationCluster` skipped non-global (V1) namespaces. Since PIP-457 (#25304, #25319), V1 topic names are gone and that check runs for every namespace. A subscribe to a missing namespace now fails with `Namespace not found` over HTTP and with `TopicNotFound` over the binary lookup, without client retries. `testTenantNotExist` in `TokenAuthenticatedProducerConsumerTest` covers this. I'm closing this PR as resolved on master. Please reopen if you still see it on a current build.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "dao-jun (via GitHub)" <gi...@apache.org>.
dao-jun closed pull request #22715: [fix] [broker] fix subscribe a non-existent cluster/namespace/topic.
URL: https://github.com/apache/pulsar/pull/22715


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "thomas-bousquet (via GitHub)" <gi...@apache.org>.
thomas-bousquet commented on code in PR #22715:
URL: https://github.com/apache/pulsar/pull/22715#discussion_r2201670345


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java:
##########
@@ -506,6 +507,18 @@ protected void validateClusterExists(String cluster) {
         }
     }
 
+    protected CompletableFuture<Void> validateNamespaceExists(NamespaceName namespace) {
+        try {
+            if (namespaceResources().namespaceExists(namespace)) {
+                return CompletableFuture.completedFuture(null);
+            } else {
+                return FutureUtil.failedFuture(new RestException(Status.NOT_FOUND, "Namespace does not exist"));
+            }
+        } catch (Exception e) {
+            return FutureUtil.failedFuture(e);
+        }
+    }
+

Review Comment:
   Is it possible the same issue is present when the tenant does not exist as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [fix] [broker] fix subscribe a non-existent cluster/namespace/topic. [pulsar]

Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat closed pull request #22715: [fix] [broker] fix subscribe a non-existent cluster/namespace/topic.
URL: https://github.com/apache/pulsar/pull/22715


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org