-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[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
@@ -216,6 +216,9 @@ | |||
private PulsarClient client = null; | |||
private ZooKeeperClientFactory zkClientFactory = null; | |||
private final String bindAddress; | |||
/** | |||
* 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.
@@ -936,7 +935,7 @@ private void updateLoadBalancingMetrics(final SystemResourceUsage systemResource | |||
List<Metrics> metrics = Lists.newArrayList(); | |||
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
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. |
@@ -38,8 +38,7 @@ | |||
public final class MultipleListenerValidator { | |||
|
|||
/** | |||
* 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 <[email protected]>
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
advertisedListeners
configuration 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 parameterignoreAdvertisedListener
with some undesirable effects:advertisedListener
though it is historically based on the web service URL. For example, theNamespaceService
usespulsar.getSafeWebServiceAddress()
as the broker name.advertisedListeners
in 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 whenadvertisedListeners
isn't configured. Also, the use ofServiceConfiguration::brokerServicePort
was 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 ofadvertisedAddress
to 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 useadvertisedListeners
when 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::getAppliedAdvertisedAddress
ServiceConfigurationUtils::getWebServiceAddress
ServiceConfigurationUtils::getInternalListener
advertisedAddress
andadvertisedListener
cannot be used at the same timePulsarService::advertisedAddress
Compatibility
This PR will impact installations of Pulsar 2.8.1 when
advertisedListeners
are 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 theadvertisedAddress
configuration property, in addition toadvertisedListeners
. TheadvertisedAddress
property 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.PulsarServiceTest
org.apache.pulsar.client.api.PulsarMultiListenersWithInternalListenerNameTest
Does 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?