nodece commented on a change in pull request #13970:
URL: https://github.com/apache/pulsar/pull/13970#discussion_r795009264



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -2720,25 +2745,58 @@ private void updatePolicies(NamespaceName ns, 
Function<Policies, Policies> updat
        }
    }
 
-    protected void internalSetNamespaceResourceGroup(String rgName) {
-        validateNamespacePolicyOperation(namespaceName, 
PolicyName.RESOURCEGROUP, PolicyOperation.WRITE);
-        validatePoliciesReadOnlyAccess();
-
-        if (rgName != null) {
-            // check resourcegroup exists.
-            try {
-                if (!resourceGroupResources().resourceGroupExists(rgName)) {
-                    throw new RestException(Status.PRECONDITION_FAILED, 
"ResourceGroup does not exist");
-                }
-            } catch (Exception e) {
-                log.error("[{}] Invalid ResourceGroup {}: {}", clientAppId(), 
rgName, e);
-                throw new RestException(e);
-            }
-        }
 
-        internalSetPolicies("resource_group_name", rgName);
+    protected void internalGetNamespaceResourceGroup(AsyncResponse 
asyncResponse, String tenant, String namespace) {
+        validateNamespacePolicyOperationAsync(NamespaceName.get(tenant, 
namespace),
+                PolicyName.RESOURCEGROUP, PolicyOperation.READ)
+                .thenCompose(__ -> getNamespacePoliciesAsync(namespaceName)
+                        .thenAccept(policies -> {
+                            log.info("[{}] Successfully to get namespace 
resource group {}/{}",
+                                    clientAppId(), tenant, namespace);
+                            asyncResponse.resume(policies.resource_group_name);
+                        }))
+                .exceptionally(ex -> {
+                    Throwable realCause = 
FutureUtil.unwrapCompletionException(ex);
+                    if (realCause instanceof WebApplicationException) {
+                        asyncResponse.resume(realCause);
+                    } else {
+                        log.error("[{}] Fail to get namespace resource group 
{}/{}", clientAppId(), tenant, namespace);

Review comment:
       You should move this to line 2760, and log `realCause`. Or miss the 
`realCause`?




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to