[broker] Fix bug that tenants whose allowed clusters include global cannot be created/updated #6275
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
If the allowed clusters include
global
, tenant creation and update will fail with the following error:However, there is actually the
global
cluster in ZK.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:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java
Lines 87 to 91 in e1357a7
global
is removed from theclusters
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 newSet
instance using stream API.In addition, allow
global
to be included in allowed clusters when creating and updating tenants, even if theglobal
cluster does not exist in the list of clusters stored in ZK. Even if theglobal
cluster is not registered in ZK, global topics will work fine.