poorbarcode commented on code in PR #21740:
URL: https://github.com/apache/pulsar/pull/21740#discussion_r1447336153


##########
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdClusters.java:
##########
@@ -130,9 +132,15 @@ void run() throws PulsarAdminException {
                         getAdmin().namespaces().deleteNamespace(namespace, 
true);
                     }
                     getAdmin().tenants().deleteTenant(tenant);
+                } else {
+                    Set<String> clusters = 
getAdmin().tenants().getTenantInfo(tenant).getAllowedClusters();
+                    clusters.remove(cluster);
+                    getAdmin().tenants().updateTenant(tenant, 
TenantInfo.builder()

Review Comment:
   So far, Pulsar did not allow to create a tenant with empty `clusters`, see 
https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java#L268-L273
   
   ```java
   // empty cluster shouldn't be allowed
   if (info == null || info.getAllowedClusters().stream().filter(c -> 
!StringUtils.isBlank(c))
           .collect(Collectors.toSet()).isEmpty()
           || info.getAllowedClusters().stream().anyMatch(ac -> 
StringUtils.isBlank(ac))) {
       log.warn("[{}] Failed to validate due to clusters are empty", 
clientAppId());
       return FutureUtil.failedFuture(new 
RestException(Status.PRECONDITION_FAILED, "Clusters can not be empty"));
   }
   ```
   
   If the `clusters` only have one element (`@param cluster`), should we delete 
this tenant or throw an error? If no, it will break the limitation above.
   
   /cc @codelipenghui @Technoboy- 



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