Skip to content

Commit

Permalink
[fix][broker] Fix geo-replication admin client url (#22584)
Browse files Browse the repository at this point in the history
(cherry picked from commit bd4c57d)
  • Loading branch information
Demogorgon314 authored and poorbarcode committed Jul 13, 2024
1 parent c0029d7 commit 3ccc213
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1535,13 +1535,11 @@ public PulsarAdmin getClusterPulsarAdmin(String cluster, Optional<ClusterData> c
}

boolean isTlsEnabled = data.isBrokerClientTlsEnabled() || conf.isBrokerClientTlsEnabled();
if (isTlsEnabled && StringUtils.isEmpty(data.getServiceUrlTls())) {
throw new IllegalArgumentException("serviceUrlTls is empty, brokerClientTlsEnabled: "
final String adminApiUrl = isTlsEnabled ? data.getServiceUrlTls() : data.getServiceUrl();
if (StringUtils.isEmpty(adminApiUrl)) {
throw new IllegalArgumentException("The adminApiUrl is empty, brokerClientTlsEnabled: "
+ isTlsEnabled);
} else if (StringUtils.isEmpty(data.getServiceUrl())) {
throw new IllegalArgumentException("serviceUrl is empty, brokerClientTlsEnabled: " + isTlsEnabled);
}
String adminApiUrl = isTlsEnabled ? data.getServiceUrlTls() : data.getServiceUrl();
builder.serviceHttpUrl(adminApiUrl);
if (data.isBrokerClientTlsEnabled()) {
configAdminTlsSettings(builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;

import com.google.common.io.Resources;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -254,9 +255,7 @@ protected void setup() throws Exception {
.brokerClientTlsTrustStoreType(keyStoreType)
.build());
admin4.clusters().createCluster(cluster4, ClusterData.builder()
.serviceUrl(url4.toString())
.serviceUrlTls(urlTls4.toString())
.brokerServiceUrl(pulsar4.getBrokerServiceUrl())
.brokerServiceUrlTls(pulsar4.getBrokerServiceUrlTls())
.brokerClientTlsEnabled(true)
.brokerClientCertificateFilePath(clientCertFilePath)
Expand All @@ -279,9 +278,20 @@ protected void setup() throws Exception {
assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrl(), url1.toString());
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrl(), url2.toString());
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrl(), url3.toString());
assertNull(admin2.clusters().getCluster(cluster4).getServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrl(), pulsar1.getBrokerServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrl(), pulsar2.getBrokerServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrl(), pulsar3.getBrokerServiceUrl());
assertNull(admin2.clusters().getCluster(cluster4).getBrokerServiceUrl());

assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrlTls(), urlTls1.toString());
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrlTls(), urlTls2.toString());
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrlTls(), urlTls3.toString());
assertEquals(admin2.clusters().getCluster(cluster4).getServiceUrlTls(), urlTls4.toString());
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrlTls(), pulsar1.getBrokerServiceUrlTls());
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrlTls(), pulsar2.getBrokerServiceUrlTls());
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrlTls(), pulsar3.getBrokerServiceUrlTls());
assertEquals(admin2.clusters().getCluster(cluster4).getBrokerServiceUrlTls(), pulsar4.getBrokerServiceUrlTls());

// Also create V1 namespace for compatibility check
admin1.clusters().createCluster("global", ClusterData.builder()
Expand Down

0 comments on commit 3ccc213

Please sign in to comment.