pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

Support multiple advertisedListener for HTTP protocol

Open wangjialing218 opened this issue 3 years ago • 4 comments

Motivation

PIP 61 and PIP 95 supports multiple advertised address for binary port. For HTTP port, currently we do not have a way to support multiple advertised address.

Consider we are deploying a broker that can be accessed through both private network (for example 192.168.0.1) and public network (for example 10.175.100.1), we could configure multiple advertised listener for binary port, Pulsar client could access broker through both private and public network with correct listener name. For HTTP address, we could only configure one advertised address through internal listener: https://github.com/apache/pulsar/blob/0cf2a7534cbcdffe7574af1ee3717fa3f7ed8ba4/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L1613

If we configure private address(192.168.0.1) for HTTP address, we may not execute some PulsarAdmin API from public network, since some http request (for example get topics' stats) may get 307 response code and redirect to another broker's private address.

Modifications

Configure multiple advertised http address in advertisedListeners together with binary address.

advertisedListeners=internal:pulsar://192.168.0.1:6650,internal:http://192.168.0.1:8080,external:pulsar://10.175.100.1:6650,external:http://10.175.100.1:8080

Broker: For HTTP request, get listener name from request header X-Pulsar-ListenerName, use the listener name for topic lookup and topic owner verification, return advertised http address in case of http redirect.

Pulsar Admin: Add listenerName to PulsarAdminBuilder, and set listener name to HTTP request header X-Pulsar-ListenerName.

Verifying this change

This change added tests and can be verified as follows: MultiHTTPAdvertisedListenersTest

Documentation

Check the box below or label this PR directly.

Need to update docs?

  • [x] doc-required Need to update doc for configuration multiple HTTP address after PR accecpt.

wangjialing218 avatar Aug 11 '22 07:08 wangjialing218

@wangjialing218 I think Pulsar have this feature for now https://github.com/apache/pulsar/pull/14839.

codelipenghui avatar Aug 11 '22 09:08 codelipenghui

@wangjialing218 I think Pulsar have this feature for now #14839.

@codelipenghui #14839 provide the feature to configure http address in advertisedListeners, but only one http address is available for http redirect: the http address of the internal listener, or the first listener which has http address in case of internal listener does not have http address.

This PR provide feature to configure multiple http address with different listener name, and provide listenerName() interface when create PulsarAdmin.

wangjialing218 avatar Aug 11 '22 09:08 wangjialing218

/pulsarbot run-failure-checks

wangjialing218 avatar Aug 12 '22 01:08 wangjialing218

The pr had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Sep 12 '22 02:09 github-actions[bot]