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
eureka: allow overriding the healthCheckUrlPath #5369
Conversation
For context, here is our custom health check controller for /health The work around is to redundantly set the same path in config just this isn't nice because it makes this log warning
p.s. I'll fix lint once I get an impression this would be an acceptable change. |
ps I can see in other tests that it is complicated to compare against the expected local host name. I'll fix that also, if someone nods the change is viable in principle. |
draft until decision is made (and I fix up is it is a go!) |
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.
Hey, thanks for the PR. 😉
I'm so happy that you've returned to maintain Zipkin!
eureka/src/main/java/com/linecorp/armeria/internal/common/eureka/InstanceInfo.java
Outdated
Show resolved
Hide resolved
65c761d
to
c3f7aa5
Compare
ok ready to go. Thanks for the tips @minwoox! |
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.
Left a couple of nits. Thanks!
InstanceStatus status, | ||
@Nullable String homePageUrl, | ||
@Nullable String statusPageUrl, | ||
@Nullable String healthCheckUrlPath, // Not in JSON |
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.
Global comment. How about just healthCheckPath
?
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.
oh I matched upstream after looking at it. I like healthCheckPath better so fine with changing it back. wdyt?
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.
Ah, then let's leave it as is. Thanks!
eureka/src/main/java/com/linecorp/armeria/internal/common/eureka/InstanceInfo.java
Show resolved
Hide resolved
secureHealthCheckUrl, oldInfo.getDataCenterInfo(), | ||
oldInfo.getLeaseInfo(), oldInfo.getMetadata()); | ||
oldInfo.getHomePageUrl(), oldInfo.getStatusPageUrl(), | ||
oldInfo.getHealthCheckUrlPath(), healthCheckUrl, secureHealthCheckUrl, |
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.
What do you think of introducing two fields?
private final InstanceInfo originalInstanceInfo;
@Nullable
private InstanceInfo filledInstanceInfo;
so that we can call the original constructor of the InstanceInfo
and make the newly-added one package-private?
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 bet your suggestion will work.. lemme think about it and try
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.
got closer.. I'll make another 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.
notes!
@@ -241,9 +251,10 @@ InstanceInfo build() { | |||
final LeaseInfo leaseInfo = new LeaseInfo(renewalIntervalSeconds, leaseDurationSeconds); | |||
return new InstanceInfo(instanceId, appName, appGroupName, hostname, ipAddr, vipAddress, |
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.
so the constructor needs to be accessible outside the package because interestingly the builder for instanceinfo is not in the same package as instanceinfo! Another way is to move this builder to common, then either re-use it here as-is, or extend or delegate to the common one.
Another way is to make a special copy factory function in instanceinfo like.. InstanceInfo.WithHealthCheckUrlPath
depends on what you feel is best (or something else, @minwoox!)
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.
Oops, I missed it. 😓 Let's leave it as is.
I will make the constructor package-private after #4243 is merged.
final String defaultHostname = server.defaultHostname(); | ||
final String hostName = oldInfo.getHostName() != null ? oldInfo.getHostName() : defaultHostname; | ||
appName = oldInfo.getAppName() != null ? oldInfo.getAppName() : hostName; |
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.
this field mutation was indescribable in the function name, so I moved it out and made the function static to prevent a recurrence!
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.
Thanks, @codefromthecrypt! 😄
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.
Looks nice! Thanks, @codefromthecrypt and @minwoox. 🙇♂️🙇♂️
final String baseURL = sessionProtocol.uriText() + "://" + | ||
hostnameOrIpAddr(hostnameOrIpAddr) + ':' + portWrapper.getPort(); | ||
if (oldHealthCheckUrlPath != null) { | ||
return baseURL + oldHealthCheckUrlPath; |
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.
Minor) Should we check if oldHealthCheckUrlPath
starts with /
when the value is first set?
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.
sure good idea
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.
PTAL
Motivation: Zipkin has a custom health check service, in addition to the normal one of type `HealthCheckService`. This is used to create a custom json response and predated our use of Armeria. This custom one is mounted at the path "/health" while the default is "/internal/health". We recently added Eureka registration, but were not able to change the path component without having to supply the scheme, host and port as well. To work around this is a bit hacky, and I would like to remove it as it cause log warnings. This change is already supported upstream for similar reasons. See https://github.com/Netflix/eureka/blob/2b09d77534eae703a36f79f99b27b4d6ed66c3f8/eureka-client/src/main/java/com/netflix/appinfo/InstanceInfo.java#L663-L666 Modifications: - Added a `healthCheckUrlPath` property to `InstanceInfo` and corresponding builders, using a custom constructor to avoid serializing it to JSON. - Modified to use this instead of the default path when set. - Added an integration test. Result: - Health check paths are overridable. Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
744860b
to
957f312
Compare
maybe there's a flakey test, can you kick 11's build?
|
Oh, please don't worry about it. 😉 |
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.
Looks good to me! Only left super minor comments regarding style. Thanks @codefromthecrypt 🙇 👍 🙇
eureka/src/main/java/com/linecorp/armeria/server/eureka/EurekaUpdatingListener.java
Outdated
Show resolved
Hide resolved
eureka/src/main/java/com/linecorp/armeria/server/eureka/EurekaUpdatingListener.java
Outdated
Show resolved
Hide resolved
eureka/src/main/java/com/linecorp/armeria/server/eureka/EurekaUpdatingListener.java
Outdated
Show resolved
Hide resolved
…UpdatingListener.java Co-authored-by: jrhee17 <guins_j@guins.org>
…UpdatingListener.java Co-authored-by: jrhee17 <guins_j@guins.org>
…UpdatingListener.java Co-authored-by: jrhee17 <guins_j@guins.org>
thanks for the help @jrhee17! |
Thanks, @codefromthecrypt! 😄 |
…reka using path properties. Motivation: Following up on the improvements introduced in line#5369, it's beneficial to extend the autofill feature to include `homePageUrl` and `statusPageUrl` of an `InstanceInfo`. This enhancement streamlines configuration by automatically populating these URLs based on corresponding path properties. Modifications: - Introduce `homePageUrlPath` and `statusPageUrlPath` properties to `InstanceInfo` and their respective builders. - Implement autofill functionality for `homePageUrl` and `statusPageUrl` using the configured path properties. Result: - `homePageUrl` and `statusPageUrl` of an `InstanceInfo` in Eureka are correctly set if corresponding path properties are configured. - Close line#5464
…reka using path properties. (#5465) Motivation: Following up on the improvements introduced in #5369, it's beneficial to extend the autofill feature to include `homePageUrl` and `statusPageUrl` of an `InstanceInfo`. This enhancement streamlines configuration by automatically populating these URLs based on corresponding path properties. Modifications: - Introduce `homePageUrlPath` and `statusPageUrlPath` properties to `InstanceInfo` and their respective builders. - Implement autofill functionality for `homePageUrl` and `statusPageUrl` using the configured path properties. Result: - `homePageUrl` and `statusPageUrl` of an `InstanceInfo` in Eureka are correctly set if corresponding path properties are configured. - Close #5464
…reka using path properties. (line#5465) Motivation: Following up on the improvements introduced in line#5369, it's beneficial to extend the autofill feature to include `homePageUrl` and `statusPageUrl` of an `InstanceInfo`. This enhancement streamlines configuration by automatically populating these URLs based on corresponding path properties. Modifications: - Introduce `homePageUrlPath` and `statusPageUrlPath` properties to `InstanceInfo` and their respective builders. - Implement autofill functionality for `homePageUrl` and `statusPageUrl` using the configured path properties. Result: - `homePageUrl` and `statusPageUrl` of an `InstanceInfo` in Eureka are correctly set if corresponding path properties are configured. - Close line#5464
Motivation:
Zipkin has a custom health check service, in addition to the normal
one of type
HealthCheckService
. This is used to create a custom jsonresponse and predated our use of Armeria. This custom one is mounted at
the path "/health" while the default is "/internal/health".
We recently added Eureka registration, but were not able to change the
path component without having to supply the scheme, host and port as
well. To work around this is a bit hacky, and I would like to remove it
as it cause log warnings.
This change is already supported upstream for similar reasons. See
https://github.com/Netflix/eureka/blob/2b09d77534eae703a36f79f99b27b4d6ed66c3f8/eureka-client/src/main/java/com/netflix/appinfo/InstanceInfo.java#L663-L666
Modifications:
healthCheckUrlPath
property toInstanceInfo
andcorresponding builders, using a custom constructor to avoid
serializing it to JSON.
Result: