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

update cf discovery defaults in service discovery #63

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

srinivasa-vasu
Copy link

  • updated reactive discovery classes to populate spring.cloud.cloudfoundry.discovery.default-server-port and spring.cloud.cloudfoundry.discovery.internal-domain if passed externally.
  • updated internal domain url to use 8080 and external route url to 80 as the default if the external input is not passed
  • removed protocol check as cf application endpoint url is not sending the protocol info in the response.
  • updated the appropriate test case

private boolean isInternalDomain(String url) {
return url != null && url.endsWith(INTERNAL_DOMAIN);
protected String getRouteURL(List<String> urls) {
return urls.stream().filter(this::isInternalDomain).findFirst().orElse("");
Copy link
Member

Choose a reason for hiding this comment

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

Don't use stream apis please

Copy link
Author

Choose a reason for hiding this comment

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

sure, changed it

@@ -85,15 +86,25 @@ protected ServiceInstance mapApplicationInstanceToServiceInstance(
String instanceId = applicationId + "." + applicationIndex;
String name = applicationDetail.getName();
String url = applicationDetail.getUrls().size() > 0
? applicationDetail.getUrls().get(0) : null;
boolean secure = (url + "").toLowerCase().startsWith("https");
Copy link
Member

Choose a reason for hiding this comment

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

Why did you change this?

Copy link
Author

@srinivasa-vasu srinivasa-vasu Feb 24, 2020

Choose a reason for hiding this comment

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

  • getUrls().get(0) always returns the external URL. It's not picking up the apps.internal url when we use CloudFoundryAppServiceReactiveDiscoveryClient
  • protocol information is never returned as part of the cf-client call. URL info always gets returned without the protocol.

@spencergibb
Copy link
Member

@making or @scottfrederick wondering if you think these changes make sense.

@srinivasa-vasu
Copy link
Author

@spencergibb is this good to go?

@spencergibb
Copy link
Member

@srinivasa-vasu I'm waiting for comment from team members.

@making
Copy link
Contributor

making commented Mar 27, 2020

@srinivasa-vasu
Let me confirm as I'm a bit confused.
If I understand correctly, CloudFoundryNativeReactiveDiscoveryClient was not supposed to be used with C2C networking and CloudFoundryAppServiceReactiveDiscoveryClient was responsible of that.
Is your commit trying to make CloudFoundryNativeReactiveDiscoveryClient available in both C2C and regular routing (via GoRouter) and it this what you want to solve in this PR?

@srinivasa-vasu
Copy link
Author

@making

  • The existing logic doesn't use C2C for CloudFoundryAppServiceReactiveDiscoveryClient. mapApplicationInstanceToServiceInstance logic in base class is used to populate DefaultServiceInstance for CloudFoundryAppServiceReactiveDiscoveryClient as well which never uses the C2C internal domain as getUrl(0) always returns the external URL. The change is to use C2C for CloudFoundryAppServiceReactiveDiscoveryClient and hence getRouteURL is defined in CloudFoundryNativeReactiveDiscoveryClient to use the external route there and overridden in CloudFoundryAppServiceReactiveDiscoveryClient to use the internal route for C2C cases.
  • port logic change is to honor the defautServerPort property in CloudFoundryAppServiceReactiveDiscoveryClient and SimpleDnsBasedReactiveDiscoveryClient for C2C cases. The default is 8080. Let's say if we explicitly the pass the value as 61001 with lb as the protocol to pass through the envoy TLS proxy port, then it will be processed.

Hope this helps.

@making
Copy link
Contributor

making commented Apr 2, 2020

@srinivasa-vasu Thanks for the clarification.
With current implementation, if more than 2 routes (e.g external url and internal url) are mapped to the app, first one is always picked up. This makes C2C unavailable even if CloudFoundryAppServiceReactiveDiscoveryClient is used because the logic is implemented in the parent class. The PR makes the logic to determine the route protected and override it to respect the internal domain in CloudFoundryAppServiceReactiveDiscoveryClient.

Is this correct? I think the change makes sense.

@srinivasa-vasu
Copy link
Author

@making Yes, that's right + the default properties update.

@srinivasa-vasu
Copy link
Author

@spencergibb can we merge this as @making seems to be fine with the changes done?

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