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 2022/04/06 12:07:43 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #15040: [branch-2.8] Fix delete namespace issue (revert and fix #14619)

Technoboy- commented on code in PR #15040:
URL: https://github.com/apache/pulsar/pull/15040#discussion_r843867753


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -284,59 +284,45 @@ protected void internalDeleteNamespace(AsyncResponse asyncResponse, boolean auth
         }
         FutureUtil.waitForAll(futures).thenCompose(__ -> {
             List<CompletableFuture<Void>> deleteBundleFutures = Lists.newArrayList();
-            return pulsar().getNamespaceService().getNamespaceBundleFactory()
-                    .getBundlesAsync(namespaceName).thenCompose(bundles -> {
-                        for (NamespaceBundle bundle : bundles.getBundles()) {
-                            // check if the bundle is owned by any broker, if not then we do not need to delete
-                            // the bundle
-                            deleteBundleFutures.add(pulsar().getNamespaceService().getOwnerAsync(bundle)
-                                    .thenCompose(ownership -> {
-                                if (ownership.isPresent()) {
-                                    try {
-                                        return pulsar().getAdminClient().namespaces()
-                                                .deleteNamespaceBundleAsync(namespaceName.toString(),
-                                                        bundle.getBundleRange());
-                                    } catch (PulsarServerException e) {
-                                        throw new RestException(e);
-                                    }
-                                } else {
-                                    return CompletableFuture.completedFuture(null);
-                                }
-                            }));
-                        }
-                        return FutureUtil.waitForAll(deleteBundleFutures);
-                    });
-        })
-        .handle((result, exception) -> {
-            if (exception != null) {
-                if (exception.getCause() instanceof PulsarAdminException) {
-                    asyncResponse.resume(new RestException((PulsarAdminException) exception.getCause()));
-                    return null;
-                } else {
-                    log.error("[{}] Failed to remove owned namespace {}", clientAppId(), namespaceName, exception);
-                    asyncResponse.resume(new RestException(exception.getCause()));
-                    return null;
-                }
-            }
-
+            NamespaceBundles bundles = null;
             try {
-                // we have successfully removed all the ownership for the namespace, the policies znode can be deleted
-                // now
-                final String globalZkPolicyPath = path(POLICIES, namespaceName.toString());
-                final String localZkPolicyPath = joinPath(LOCAL_POLICIES_ROOT, namespaceName.toString());
-                namespaceResources().delete(globalZkPolicyPath);
-                try {
-                    getLocalPolicies().delete(localZkPolicyPath);
-                } catch (NotFoundException nne) {
-                    // If the z-node with the modified information is not there anymore, we're already good
-                }
+                bundles = pulsar().getNamespaceService().getNamespaceBundleFactory()
+                        .getBundles(namespaceName);

Review Comment:
   Why change this to sync ? I mean `getBundles`, not `getBundlesAsync`?



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