Skip to content
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

[FLINK-31518][Runtime / REST] Fix StandaloneHaServices#getClusterRestEndpointLeaderRetreiver to return correct rest port #22308

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Samrat002
Copy link
Contributor

What is the purpose of the change

Currently, StandaloneHaServices#getClusterRestEndpointLeaderRetreiver returns wrong rest port when a range of ports is configured in rest.port. This patch addresses the same.

Brief change log

DefaultDispatcherResourceManagerComponentFactory sets the configuration with the rest address and rest port, from which the StandaloneHaServices#getClusterRestEndpointLeaderRetriever retrieves the address and port.

Verifying this change

This change added tests and can be verified as follows:

  1. Run a flink job with config rest.port set to a range say 50200-50300.
  2. Included below code in a thread launched by the Adaptive Scheduler.
LeaderRetrievalService webMonitorRetrievalService = highAvailabilityServices.getClusterRestEndpointLeaderRetriever();
try {
webMonitorRetrievalService.start(new WebMonitorLeaderListener());
} catch (Exception e) {
throw new RuntimeException(e);
}

private class WebMonitorLeaderListener implements LeaderRetrievalListener {
@OverRide
public void notifyLeaderAddress(final String leaderAddress, final UUID leaderSessionID) {
System.out.println(leaderAddress);
}
  1. The leader address printed is the correct one which RestServerEndpoint listens.

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

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Mar 30, 2023

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@Samrat002
Copy link
Contributor Author

@huwh please review the changes in free time

…EndpointLeaderRetreiver to return correct rest port
Copy link
Contributor

@huwh huwh left a comment

Choose a reason for hiding this comment

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

Thanks for preparing this PR. I left some comments.

Currently there is no internal components in JobManager will call web monitor. So maybe we could not change the HighAvailableService and just update this configuration when WebMonitor is started is enough.

Then you can use ClientHighAvailabilityServices to retrieve the right web address and port.

And looking forward to your opinion @dannycranmer

@@ -176,6 +176,10 @@ public DispatcherResourceManagerComponent create(
log.debug("Starting Dispatcher REST endpoint.");
webMonitorEndpoint.start();

configuration.setInteger(RestOptions.PORT, webMonitorEndpoint.getRestPort());
configuration.setString(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need update this Address?

"getServerAddress()" may produce NPE here.


return new StandaloneHaServices(
resourceManagerRpcUrl, dispatcherRpcUrl, webMonitorAddress);
resourceManagerRpcUrl, dispatcherRpcUrl, configuration);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need these change if you use ClientHighAvailabilityServices to retrieve the rest address and port?

@1996fanrui 1996fanrui self-requested a review July 12, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants