-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Issue 12040][broker] Fix advertised listener confusion #12353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue 12040][broker] Fix advertised listener confusion #12353
Conversation
- deprecate ServiceConfigurationUtils::getAppliedAdvertisedAddress - clarify the purpose of PulsarService::advertisedAddress - introduce a helper method for webServiceAddress - stabilize the ordering of advertised listeners
- checkstyle
| /** | ||
| * The host component of the broker's canonical name. | ||
| */ | ||
| private final String advertisedAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am inclined to deprecate the advertisedAddress in favor of a formal broker name property. In a follow-up PR, we could introduce a BrokerName type (as opposed to a String) to help with refactoring. For this PR, I left advertisedAddress as-is but clarified its purpose.
| Map<String, String> dimensions = new HashMap<>(); | ||
|
|
||
| dimensions.put("broker", ServiceConfigurationUtils.getAppliedAdvertisedAddress(conf, true)); | ||
| dimensions.put("broker", pulsar.getAdvertisedAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the broker dimension represents the broker canonical name, not any particular network address. The effective value is unchanged.
-bugfix
- updated tests - remove obsolete validation check
…pplied-listener # Conflicts: # pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfigurationUtils.java
eolivelli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Hi @EronWright since the due date of 2.9.0 went past, do you still want this PR to scope in 2.9.0? |
|
@Anonymitaet yes I believe it an important fix for 2.9. |
|
I am fixing the Broker Client test failure. The issue is that this PR fixes the broker address in Update: fixed by introducing a simple port forwarder into the test setup to forward traffic from the advertised port to the listen port. This makes the test stronger because we're testing the independence of those two ports. |
|
/pulsarbot run-failure-checks |
- add a utility class for local port-forwarding - enhance the MockedPulsarServiceBaseTest to port-forward from advertised port to listen port - fix the PulsarMultiListenersWithInternalListenerNameTest
|
@315157973 Please help review the PR since you have more context about this part. |
| * validate the configure of `advertisedListeners`, `internalListenerName`, `advertisedAddress`. | ||
| * 1. `advertisedListeners` and `advertisedAddress` must not appear together. | ||
| * Validate the configuration of `advertisedListeners`, `internalListenerName`. | ||
| * 2. the listener name in `advertisedListeners` must not duplicate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to change the java doc here, starting from 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomscut can you please send a PR to fix this ?
I am going to merge this patch now and prepare 2.9.0 release soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### Motivation *Fix the java doc mentioned in [#12353](https://github.com/apache/pulsar/pull/12353/files#r729887373)* ### Modifications *Fix java doc for MultipleListenerValidator#validateAndAnalysisAdvertisedListener.*
### Motivation *Fix the java doc mentioned in [#12353](https://github.com/apache/pulsar/pull/12353/files#r729887373)* ### Modifications *Fix java doc for MultipleListenerValidator#validateAndAnalysisAdvertisedListener.* (cherry picked from commit 9d10b8b)
* [Issue 12040] - deprecate ServiceConfigurationUtils::getAppliedAdvertisedAddress - clarify the purpose of PulsarService::advertisedAddress - introduce a helper method for webServiceAddress - stabilize the ordering of advertised listeners - add a utility class for local port-forwarding - enhance the MockedPulsarServiceBaseTest to port-forward from advertised port to listen port - fix the PulsarMultiListenersWithInternalListenerNameTest Co-authored-by: penghui <penghui@apache.org>

Master Issue: #12040
Motivation
A couple of PRs (#10312 and #10961) caused an unintended change to the broker address that is used in various scenarios. There are three important cases to consider:
pulsar://andpulsar+ssl://)http://andhttps://)Note that the
advertisedListenersconfiguration property is designed to support the broker service URL only, not the web service URL. Support for multiple web addresses will be addressed later.The first PR unintentionally caused the web service URL to be derived from
advertisedListeners. This caused #10951 and led to the second PR. The second PR introduced a parameterignoreAdvertisedListenerwith some undesirable effects:advertisedListenerthough it is historically based on the web service URL. For example, theNamespaceServiceusespulsar.getSafeWebServiceAddress()as the broker name.advertisedListenersin computingPulsarService::brokerUrl, which is used for intra-cluster communication (eg. by the function worker).advertisedListeners.Modifications
This PR cleans up the code to use the correct identifier for each case.
For the broker service URL, a helper method is introduced (
ServiceConfigurationUtils::getInternalListener) to obtain the endpoint to be used for intra-cluster connectivity. This is designed to work in all cases, even whenadvertisedListenersisn't configured. Also, the use ofServiceConfiguration::brokerServicePortwas minimized for interoperability with #12079.For the web service URL, a helper method is introduced (
ServiceConfigurationUtils::getWebServiceAddress) to encapsulate the logic and to help with future enhancements. This PR re-enables the use ofadvertisedAddressto configure the web service URL, independent of theadvertisedListeners.For the broker canonical name, the codebase typically use
PulsarService::getAdvertisedAddress. The value is simply a hostname and should never be used to connect to the broker; it is strictly for identification purposes. Historically the value is derived from the web service URL, not the broker service URL. For that reason, this PR doesn't useadvertisedListenerswhen computing the canonical name.To test the decoupling of advertised port from listen port, a test case was enhanced to use a simple port forwarder.
Specific changes:
ServiceConfigurationUtils::getAppliedAdvertisedAddressServiceConfigurationUtils::getWebServiceAddressServiceConfigurationUtils::getInternalListeneradvertisedAddressandadvertisedListenercannot be used at the same timePulsarService::advertisedAddressCompatibility
This PR will impact installations of Pulsar 2.8.1 when
advertisedListenersare configured. This is because #10961 was included in 2.8.1 and has various effects (as mentioned above). This PR will restore the original behavior. A possible mitigation strategy is to set theadvertisedAddressconfiguration property, in addition toadvertisedListeners. TheadvertisedAddressproperty is the basis for the broker canonical name; set it to the hostname of the internal advertised listener to avoid a change to the effective values when upgrading from 2.8.1 to 2.9.Followups
ServiceConfigurationUtils::getInternalListener(see: Apply new getAppliedAdvertisedAddress signature streamnative/aop#242)Verifying this change
(Please pick either of the following options)
Unit tests were added or updated to:
org.apache.pulsar.broker.PulsarServiceTestorg.apache.pulsar.client.api.PulsarMultiListenersWithInternalListenerNameTestDoes this pull request potentially affect one of the following parts:
Documentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?