apache/pulsar · error · RestException

Allowed clusters do not contain the replication cluster %s.

Error message

Allowed clusters do not contain the replication cluster %s. Please remove the replication cluster if the cluster is not allowed for this namespace

What it means

internalSetNamespaceAllowedClusters rejects adding a replication cluster to the namespace that is not part of the tenant's allowedClusters list; this is a tenant/namespace consistency precondition failure (412).

Source

Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:3429

                    }
                    return policiesOpt.map(p -> p.dispatcherPauseOnAckStatePersistentEnabled).orElse(false);
                });
    }

    protected CompletableFuture<Void> internalSetNamespaceAllowedClusters(List<String> clusterIds) {
        return validateNamespacePolicyOperationAsync(namespaceName, PolicyName.ALLOW_CLUSTERS, PolicyOperation.WRITE)
                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
                // Allowed clusters in the namespace policy should be included in the allowed clusters in the tenant
                // policy.
                .thenCompose(__ -> FutureUtil.waitForAll(clusterIds.stream().map(clusterId ->
                        validateClusterForTenantAsync(namespaceName.getTenant(), clusterId))
                        .collect(Collectors.toList())))
                .thenCompose(__ -> {
                    checkNotNull(clusterIds, "ClusterIds should not be null");
                    return getNamespacePoliciesAsync(this.namespaceName).thenApply(nsPolicies -> {
                        Set<String> clusterSet = Sets.newHashSet(clusterIds);
                        if (!Policies.checkNewAllowedClusters(nsPolicies, clusterSet)){
                            throw new RestException(Status.BAD_REQUEST,
                                    String.format("Allowed clusters do not contain the replication cluster %s. "
                                        + "Please remove the replication cluster if the cluster is not allowed "
                                        + "for this namespace", nsPolicies.replication_clusters));
                        }
                        return clusterSet;
                    });
                })
                // Verify the allowed clusters are valid and they do not contain the peer clusters.
                .thenCompose(allowedClusters -> clustersAsync()
                        .thenCompose(clusters -> {
                            List<CompletableFuture<Void>> futures =
                                    allowedClusters.stream().map(clusterId -> {
                                        if (!clusters.contains(clusterId)) {
                                            throw new RestException(Status.FORBIDDEN,
                                                    "Invalid cluster id: " + clusterId);
                                        }
                                        return validatePeerClusterConflictAsync(clusterId, allowedClusters);
                                    }).collect(Collectors.toList());

View on GitHub (pinned to 820761864e)

Solutions

  1. Add the cluster to the tenant's allowedClusters first, then set namespace replication clusters
  2. Remove the disallowed cluster from the namespace's replicationClusters set
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:3429 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/add2fc4821b8be59. Report an issue: GitHub.