[fix][client] Fix tenant's allowedClusters is not updated when removing cluster#21740
[fix][client] Fix tenant's allowedClusters is not updated when removing cluster#21740ubo-dev wants to merge 0 commit intoapache:masterfrom
allowedClusters is not updated when removing cluster#21740Conversation
|
I did try to add some test for this case but I have struggled a little. In AdminApiTest class there is a test that is for listing, creation, deletion for clusters. When I try to test this case, it does not run through CmdClusters, so I couldn't test it. |
Add test in |
|
@Technoboy- I have added delete cluster without delete all option test. Could you review it? |
|
Hey, I've accidentally closed the PR, I've added the required tests and opened it again @Technoboy- Could you review it? |
allowedClusters is not updated when removing cluster
| } else { | ||
| Set<String> clusters = getAdmin().tenants().getTenantInfo(tenant).getAllowedClusters(); | ||
| clusters.remove(cluster); | ||
| getAdmin().tenants().updateTenant(tenant, TenantInfo.builder() |
There was a problem hiding this 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
// 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.
There was a problem hiding this comment.
IMO, we should throw an error since tenant with empty clusters is not allowed. @Technoboy- @poorbarcode
Fixes #21546
Main Issue: #21546
Motivation
After deletion of cluster, tenant's allowed clusters Set is not updated. The deleted clusters is still available in there.
Modifications
I have edited the delete cluster method in CmdCluster file to update tenant's allowed cluster set when deletion of cluster occurs.
Verifying this change
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: PR