You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/10/11 00:42:14 UTC

[GitHub] [pulsar] LeBW commented on a change in pull request #12215: fix delete authentication policies when delete topic.

LeBW commented on a change in pull request #12215:
URL: https://github.com/apache/pulsar/pull/12215#discussion_r725727909



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -982,6 +986,28 @@ public void deleteLedgerFailed(ManagedLedgerException exception, Object ctx) {
         return future;
     }
 
+    public void deleteTopicAuthenticationWithRetry(String topic) {
+        pulsar.getPulsarResources().getNamespaceResources()
+                .setPoliciesAsync(TopicName.get(topic).getNamespaceObject(), p -> {
+                    p.auth_policies.getTopicAuthentication().remove(topic);
+                    return p;
+                }).thenAccept(r2 -> {
+                    log.info("Successfully delete authentication policies for topic {}", topic);
+                }).exceptionally(ex1 -> {
+                    if (ex1.getCause() instanceof MetadataStoreException.BadVersionException) {
+                        log.warn(
+                                "Failed to delete authentication policies because of bad version. "
+                                        + "Retry to delete authentication policies for topic {}",
+                                topic);
+                        deleteTopicAuthenticationWithRetry(topic);
+                    } else {
+                        log.error("Failed to delete authentication policies for topic {}", topic);
+                        ex1.printStackTrace();

Review comment:
       Fixed.




-- 
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