Skip to content

Conversation

@dmunozv04
Copy link

@dmunozv04 dmunozv04 commented Sep 30, 2025

This PR allows to set Tomcat's HealthCheckValve with environment variables. The implementation is taken from the RemoteIpValve script.

EDIT: this is useful so orchestrators (like kubernetes) or docker itself can know if the service is ready to accept connections.

The second commit uses these new variables to configure docker's HEALTHCHECK. This could be removed if it shouldn't be enabled by default.

I'm happy to make any changes necessary. Thanks for reviewing this PR.

Copy link
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

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

The changes look pretty good to me - the only thing that needs to be addressed is that the PR title needs the correct formatting for the Jira prefix:
GUACAMOLE-2086:

@dmunozv04 dmunozv04 changed the title Guacamole 2086: Add Tomcat HealthCheckValve GUACAMOLE-2086: Add Tomcat HealthCheckValve Sep 30, 2025
@dmunozv04
Copy link
Author

Fixed, sorry for that

@dmunozv04 dmunozv04 requested a review from necouchman October 1, 2025 06:59
@dmunozv04 dmunozv04 force-pushed the GUACAMOLE-2086-HealthCheckValve branch from 075340e to a10f9d8 Compare October 11, 2025 13:06
Comment on lines +31 to +35
if [ "$HEALTH_CHECK_VALVE_ENABLED" = "true" ]; then
# Default health check path (/health)
HEALTH_CHECK_PATH="${HEALTH_CHECK_VALVE_PATH:-/health}"
# Perform actual health check via curl
curl --fail --silent --show-error "http://localhost:8080${HEALTH_CHECK_PATH}" || exit 1
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of concerns about the HEALTH_CHECK_VALVE_PATH variable:

  • It looks like it assumes that an absolute path will be provided?
  • What happens if the user provides a relative path (no leading /), both here and in the server.xml file?

Copy link
Author

Choose a reason for hiding this comment

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

I assumed an absolute path would be provided since it looks like tomcat only supports absolute paths:
https://github.com/apache/tomcat/blob/eaea7503163e44ba7260c9c7b3af3f4ba387d072/java/org/apache/catalina/valves/HealthCheckValve.java#L82

If the user provides a relative path, the health check won't be reachable and curl will complain: "curl: (3) URL rejected: Port number was not a decimal number between 0 and 65535\n"

Maybe a check can be added when loading the variables to warn the user if the path is not absolute.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I would think checking the variable would be the right way to go...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants