Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[broker] Fix bug that tenants whose allowed clusters include global cannot be created/updated #6275

Merged
merged 1 commit into from
Feb 12, 2020

Conversation

massakam
Copy link
Contributor

@massakam massakam commented Feb 8, 2020

Motivation

If the allowed clusters include global, tenant creation and update will fail with the following error:

$ pulsar-admin tenants create -r xxx.xxx.xxx -c global,dev1,dev2 sample-tenant

Clusters do not exist

Reason: Clusters do not exist

However, there is actually the global cluster in ZK.

[zk: localhost:2184(CONNECTED) 14] ls /admin/clusters

[dev1, dev2, global]

As a result of the investigation, I found that global was removed from the cluster list in the configuration store cache after getting the list of clusters by the REST API. This is due to the following:

Set<String> clusters = clustersListCache().get();
// Remove "global" cluster from returned list
clusters.remove(Constants.GLOBAL_CLUSTER);
return clusters;

global is removed from the clusters variable, which seems to be not a deep copy but a shallow copy.

Modifications

When getting the list of clusters from the configuration store and deleting global from it, create a new Set instance using stream API.

Set<String> clusters = clustersListCache().get().stream()
        .filter(cluster -> !Constants.GLOBAL_CLUSTER.equals(cluster)).collect(Collectors.toSet());

In addition, allow global to be included in allowed clusters when creating and updating tenants, even if the global cluster does not exist in the list of clusters stored in ZK. Even if the global cluster is not registered in ZK, global topics will work fine.

@massakam massakam added type/bug The PR fixed a bug or issue reported a bug area/broker release/2.5.1 labels Feb 8, 2020
@massakam massakam added this to the 2.6.0 milestone Feb 8, 2020
@massakam massakam self-assigned this Feb 8, 2020
@merlimat merlimat merged commit 4264b8d into apache:master Feb 12, 2020
@massakam massakam deleted the tenant-global-cluster branch February 13, 2020 05:23
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Feb 23, 2020
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Mar 21, 2020
tuteng pushed a commit that referenced this pull request Apr 6, 2020
tuteng pushed a commit that referenced this pull request Apr 13, 2020
jiazhai pushed a commit to jiazhai/pulsar that referenced this pull request May 18, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker release/2.5.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants