Skip to content

Fix incorrect port of advertisedListener - #10961

Merged
sijie merged 6 commits into
apache:masterfrom
315157973:port2
Jun 22, 2021
Merged

sijie merged 6 commits into
apache:masterfrom
315157973:port2

Conversation

@315157973

Copy link
Copy Markdown
Contributor

Fixes #10951

Motivation

The advertisedListener has its own port, and now we have no way to obtain the port of TLS and non-TLS advertisedListener except by setting the listenerName through the client.
Therefore, brokerServiceUrl and webServiceUrl do not return the address and port of the advertisedListener

@315157973

Copy link
Copy Markdown
Contributor Author

Hello @abhilashmandaliya . Thanks for your feedback.
Address returned by the method does not correspond to the port. I have fix it in this PR

return shutdownService;
}

public static String advertisedAddress(ServiceConfiguration config) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the difference of this method compared to org.apache.pulsar.broker.ServiceConfigurationUtils.getAppliedAdvertisedAddress added in #10312 ?

Would it be possible to add javadoc with the explanation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@315157973 Great. It is still a bit unclear to me what is the difference of this method compared to org.apache.pulsar.broker.ServiceConfigurationUtils.getAppliedAdvertisedAddress added in #10312 . Do you have an answer for that question?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The order of getAppliedAdvertisedAddress() to obtains addresses is:
AdvertisedAddress, advertisedListener, hostname
The order of advertisedAddress() to obtain addresses is:
AdvertisedAddress, hostname

Why the advertisedAddress() method does not obtain the advertisedListener has been described in PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the advertisedAddress() method does not obtain the advertisedListener has been described in PR

It's not clear to me how it is described. Could you elaborate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PTAL. Do you have any suggestions for the comments?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The difference between PulsarService.advertisedAddress and org.apache.pulsar.broker.ServiceConfigurationUtils.getAppliedAdvertisedAddress hasn't been addressed in the code comments. That was my original feedback.

It seems wrong to have duplication in code between PulsarService and ServiceConfigurationUtils without a clear distinction. There would be no need to clarify this duplication if there's a way to eliminate the duplication. Do you have a way to resolve the duplication with further refactoring?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about add such an method in ServiceConfigurationUtils?

getAppliedAdvertisedAddress(ServiceConfiguration configuration, boolean ignoreAdvertisedListener)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about add such an method in ServiceConfigurationUtils?

getAppliedAdvertisedAddress(ServiceConfiguration configuration, boolean ignoreAdvertisedListener)

👍 I think this could resolve the issue. Documenting the reason and meaning of ignoreAdvertisedListener in javadoc would be helpful.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@315157973 pls ping me if you need doc review

@lhotari lhotari added release/2.8.1 type/bug The PR fixed a bug or issue reported a bug labels Jun 17, 2021
@lhotari lhotari added this to the 2.9.0 milestone Jun 17, 2021
@Anonymitaet

Copy link
Copy Markdown
Member

@315157973 thanks for your contribution. For this PR, do we need to update docs?

@315157973

Copy link
Copy Markdown
Contributor Author

@315157973 thanks for your contribution. For this PR, do we need to update docs?

No, this is just an internal method

@abhilashmandaliya

Copy link
Copy Markdown
Contributor

I think we should have exposed advertised ports like an advertisedAddress. I am not sure about the impact of this fix but in general, it still looks odd. We may get advertisedAddress and normal broker port. We could have avoided advertisedListner if we had exposed advertisedBrokerPort and adverisedWebPort? If I am not wrong advertisedListener 's port is only for broker, not for web.

@315157973

Copy link
Copy Markdown
Contributor Author

I think we should have exposed advertised ports like an advertisedAddress. I am not sure about the impact of this fix but in general, it still looks odd. We may get advertisedAddress and normal broker port. We could have avoided advertisedListner if we had exposed advertisedBrokerPort and adverisedWebPort? If I am not wrong advertisedListener 's port is only for broker, not for web.

Yes, it has now been changed to only get advertisedAddress and hostname. Will not be affected by advertisedListner.

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@sijie
sijie merged commit 99c84c4 into apache:master Jun 22, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
Fixes apache#10951

### Motivation
The advertisedListener has its own port, and now we have no way to obtain the port of TLS and non-TLS advertisedListener except by setting the listenerName through the client.
Therefore, brokerServiceUrl and webServiceUrl do not return the address and port of the advertisedListener
codelipenghui pushed a commit that referenced this pull request Jun 25, 2021
Fixes #10951

### Motivation
The advertisedListener has its own port, and now we have no way to obtain the port of TLS and non-TLS advertisedListener except by setting the listenerName through the client.
Therefore, brokerServiceUrl and webServiceUrl do not return the address and port of the advertisedListener


(cherry picked from commit 99c84c4)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jun 25, 2021
@315157973
315157973 deleted the port2 branch July 19, 2021 11:10
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
Fixes apache#10951

### Motivation
The advertisedListener has its own port, and now we have no way to obtain the port of TLS and non-TLS advertisedListener except by setting the listenerName through the client.
Therefore, brokerServiceUrl and webServiceUrl do not return the address and port of the advertisedListener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.8 Archived: 2.8 is end of life release/2.8.1 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function worker uses raw webService Port against adverisedListener and advertisedAddress

8 participants