Skip to content

[PIP 95][Issue 12040][broker] Decouple advertised listeners from bind addresses#12079

Merged
eolivelli merged 5 commits intoapache:masterfrom
streamnative:ewright/pip95-decouple
Oct 15, 2021
Merged

[PIP 95][Issue 12040][broker] Decouple advertised listeners from bind addresses#12079
eolivelli merged 5 commits intoapache:masterfrom
streamnative:ewright/pip95-decouple

Conversation

@EronWright
Copy link
Contributor

@EronWright EronWright commented Sep 17, 2021

Master Issue: #12040
Related: #3501

Motivation

This PR decouples the advertised listener configuration from the broker bind addresses, and fixes a few places where the broker is assumed to have a plaintext cluster endpoint or conflates the TLS/plaintext endpoints.

The goal is to support a specific configuration, where the broker has an advertised listener corresponding to an Istio gateway, and the gateway terminates TLS (pulsar+ssl://broker1.gateway:6651/). Because Istio uses mTLS transparently within the mesh, the broker has only a plaintext server endpoint (pulsar://broker1.cluster:6650/). Without this patch, the broker rejects the configuration because it erroneously assumes that the broker should have a TLS binding to support a TLS advertised address.

This PR deprecates the PulsarService::getSafeBrokerServiceUrl method, which returns a plaintext endpoint if available, and a TLS endpoint otherwise. The resultant endpoint is then advertised to Pulsar clients but the scheme information isn't always considered. Observe that client code disregards the scheme in some cases:

if (useTls) {
uri = new URI(lookupData.getBrokerUrlTls());
} else {
String serviceUrl = lookupData.getBrokerUrl();
if (serviceUrl == null) {
serviceUrl = lookupData.getNativeUrl();
}
uri = new URI(serviceUrl);
}
InetSocketAddress brokerAddress = InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort());

Note that this PR is focused on the Pulsar protocol endpoints, not the REST API endpoints.

Modifications

  • Remove validation logic that compares the advertised listener against the bind addresses.
  • Deprecate PulsarService::getSafeBrokerServiceUrl and be explicit about which address is used.
  • Update broker code to not assume there's a plaintext endpoint for a given advertised listener (it might be pure-TLS).

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as:

  • MultipleListenerValidatorTest

Does this pull request potentially affect one of the following parts:

  • The public API: yes

The information that is returned by the broker is slightly different in the case of a pure-TLS broker. In that case, lookup results (which consist of a pair of URLs) might not have a plaintext URL. In concept a client could break, though in practice this is unlikely since the broker didn't really work in such a configuration anyway.

Documentation

Need to update docs?

  • no-need-doc

Internal changes.

@Anonymitaet Anonymitaet added the doc-not-needed Your PR changes do not impact docs label Sep 18, 2021
@codelipenghui codelipenghui added this to the 2.9.0 milestone Sep 18, 2021
@eolivelli eolivelli changed the title [Issue 12040][broker] Decouple advertised listeners from bind addresses [PIP 95][Issue 12040][broker] Decouple advertised listeners from bind addresses Sep 20, 2021
@eolivelli eolivelli modified the milestones: 2.9.0, 2.10.0 Oct 6, 2021
# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/MessagingServiceShutdownHook.java
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/NoopLoadManager.java
@codelipenghui codelipenghui modified the milestones: 2.10.0, 2.9.0 Oct 14, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli eolivelli merged commit 38539b3 into apache:master Oct 15, 2021
@codelipenghui codelipenghui deleted the ewright/pip95-decouple branch October 15, 2021 11:31
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants