World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#10846] fix(server): Add /health.html alias for legacy GTM standards (#10847)
Mark Hoerth75deae2b10fe
diff --git a/docs/open-api/health.yaml b/docs/open-api/health.yamlindex d6956446bd..dd4be8bdae 100644--- a/docs/open-api/health.yaml+++ b/docs/open-api/health.yaml@@ -29,6 +29,8 @@ paths:Returns aggregate health status combining liveness and readiness checks.Returns 200 when all checks pass; 503 when any check fails.This endpoint is exempt from authentication so probes can reach it without credentials.+ Root-level aliases at /health and /health.html (outside the /api base path) are also+ available for GTMs that require probes at well-known root paths.security: []responses:"200":@@ -50,6 +52,8 @@ paths:Returns 200 as long as the HTTP server thread can respond.Use this for Kubernetes liveness probes to determine whether to restart a pod.This endpoint is exempt from authentication so probes can reach it without credentials.+ A root-level alias at /health/live (outside the /api base path) is also available+ for GTMs that require probes at well-known root paths.security: []responses:"200":@@ -70,6 +74,8 @@ paths:Returns 503 when the entity store is unavailable or slow.Use this for Kubernetes readiness probes to control traffic routing.This endpoint is exempt from authentication so probes can reach it without credentials.+ A root-level alias at /health/ready (outside the /api base path) is also available+ for GTMs that require probes at well-known root paths.security: []responses:"200":diff --git a/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java b/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.javaindex 66a05bd485..f91a55607a 100644--- a/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java+++ b/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java@@ -140,10 +140,11 @@ public class AuthenticationFilter implements Filter {if (path == null) {return false;}- // Also match /health and /health/* — the root-level aliases that forward to /api/health/*.- // During a forward, getRequestURI() returns the original URI, not the forwarded target.+ // Also match /health, /health/*, and /health.html — root-level aliases that forward to+ // /api/health/*. During a forward, getRequestURI() returns the original URI, not the target.return path.equals("/health")|| path.startsWith("/health/")+ || path.equals("/health.html")|| path.equals("/api/health")|| path.startsWith("/api/health/");}diff --git a/server-common/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticationFilter.java b/server-common/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticationFilter.javaindex 7366b89db6..8c227727b4 100644--- a/server-common/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticationFilter.java+++ b/server-common/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticationFilter.java@@ -132,6 +132,7 @@ public class TestAuthenticationFilter {"/health","/health/live","/health/ready",+ "/health.html","/api/health","/api/health/","/api/health/live",diff --git a/server/src/main/java/org/apache/gravitino/server/GravitinoServer.java b/server/src/main/java/org/apache/gravitino/server/GravitinoServer.javaindex dc8dda7362..0d45a57721 100644--- a/server/src/main/java/org/apache/gravitino/server/GravitinoServer.java+++ b/server/src/main/java/org/apache/gravitino/server/GravitinoServer.java@@ -177,9 +177,11 @@ public class GravitinoServer extends ResourceConfig {Servlet configServlet = new ConfigServlet(serverConfig);server.addServlet(configServlet, "/configs");- // Root-level alias for enterprise GTMs that require probes at well-known root paths.- // Forwards /health, /health/live, /health/ready to the canonical /api/health/* endpoints.+ // Root-level aliases for enterprise GTMs that require probes at well-known root paths.+ // Forwards /health, /health/live, /health/ready, and /health.html to the canonical+ // /api/health/* endpoints.server.addServlet(new HealthAliasServlet(), "/health/*");+ server.addServlet(new HealthAliasServlet(), "/health.html");server.addCustomFilters(API_ANY_PATH);server.addFilter(new VersioningFilter(), API_ANY_PATH);diff --git a/server/src/main/java/org/apache/gravitino/server/web/HealthAliasServlet.java b/server/src/main/java/org/apache/gravitino/server/web/HealthAliasServlet.javaindex daf21b9057..532bc44e4a 100644--- a/server/src/main/java/org/apache/gravitino/server/web/HealthAliasServlet.java+++ b/server/src/main/java/org/apache/gravitino/server/web/HealthAliasServlet.java@@ -26,8 +26,8 @@ import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;/**- * Serves root-level health paths ({@code /health}, {@code /health/live}, {@code /health/ready}) by- * forwarding to the canonical {@code /api/health/*} endpoints.+ * Serves root-level health paths ({@code /health}, {@code /health/live}, {@code /health/ready},+ * {@code /health.html}) by forwarding to the canonical {@code /api/health/*} endpoints.** <p>This alias exists for compatibility with enterprise global traffic managers that require* probes at well-known root paths. The canonical implementation remains at {@code /api/health}.@@ -37,8 +37,11 @@ public class HealthAliasServlet extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {- // Prepend /api to the incoming path: /health → /api/health, /health/live → /api/health/live- String targetPath = "/api" + req.getRequestURI();+ // Map root-level health paths to their canonical /api/health counterparts.+ // /health and /health.html both target the aggregate /api/health; legacy GTM+ // standards sometimes hardcode the .html extension.+ String uri = req.getRequestURI();+ String targetPath = "/health.html".equals(uri) ? "/api/health" : "/api" + uri;RequestDispatcher dispatcher = req.getRequestDispatcher(targetPath);if (dispatcher == null) {resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "health dispatcher unavailable");diff --git a/server/src/test/java/org/apache/gravitino/server/web/TestHealthAliasServlet.java b/server/src/test/java/org/apache/gravitino/server/web/TestHealthAliasServlet.javaindex 876af0111b..1d0e6e3e8a 100644--- a/server/src/test/java/org/apache/gravitino/server/web/TestHealthAliasServlet.java+++ b/server/src/test/java/org/apache/gravitino/server/web/TestHealthAliasServlet.java@@ -34,6 +34,7 @@ public class TestHealthAliasServlet {@ParameterizedTest@CsvSource({"/health, /api/health",+ "/health.html, /api/health","/health/live, /api/health/live","/health/ready, /api/health/ready"})