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

GeoNetwork healthcheck and ApplicationFilter #150

Open
plecor opened this issue Nov 27, 2024 · 2 comments
Open

GeoNetwork healthcheck and ApplicationFilter #150

plecor opened this issue Nov 27, 2024 · 2 comments
Assignees

Comments

@plecor
Copy link

plecor commented Nov 27, 2024

I'm not sure if this is the right place for this issue on an interaction between GeoNetwork and Gateway. Feel free to move it if pertinent.

GeoNetwork warning (and I assume critical) healthchecks return an HTTP response with code 500 and a JSON body, for instance:

[
    {
    "name": "DashboardAppHealthCheck",
    "status": "OK",
    "msg": "Dashboard application is running."
  },
    {
    "name": "DeadlockedThreadsHealthCheck",
    "status": "OK"
  },
    {
    "name": "Free file handles",
    "status": "OK"
  },
    {
    "name": "FreeConnectionsHealthCheck",
    "status": "OK"
  },
    {
    "name": "HarvestersHealthCheck",
    "status": "OK"
  },
    {
    "name": "IndexReadOnlyHealthCheck",
    "status": "OK",
    "msg": "Index is writable."
  },
    {
    "name": "NoIndexErrorsHealthCheck",
    "status": "ERROR",
    "msg": "Found 37 metadata that had errors during indexing"
  }
]

Geonetwork then parses this JSON response to display a warning popup or to show the healthcheck results in the admin console (geonetwork/srv/eng/admin.console#/dashboard).

But with Gateway default config, the ApplicationError filter rewrites the HTTP Response to:

{
    "timestamp": "2024-11-27T13:21:17.917+00:00",
    "path": "/geonetwork/warninghealthcheck",
    "status": 500,
    "error": "Internal Server Error",
    "message": null,
    "requestId": "9731f6ce-109"
}

causing a Javascript error trying to parse healthCheck[o.name] and breaking the template from the status dashboard.

Explicitely removing the ApplicationFilter from the default-filters remove this issue:

 default-filters:
      - SecureHeaders
      - TokenRelay
      - RemoveSecurityHeaders
      # AddSecHeaders appends sec-* headers to proxied requests based on the currently authenticated user
      - AddSecHeaders
      - PreserveHostHeader
        #  - ApplicationError
      - LoginParamRedirect

but it seems a bit excessive. Is there any way to exclude the ApplicationError filter for some specific routes?

@plecor
Copy link
Author

plecor commented Nov 27, 2024

I think 0beae05 was trying to fix this, but the healthcheck request has an Accept: application/json, text/plain, */* header, meaning the following test:

  boolean acceptsHtml(ServerHttpRequest request) {
        return request.getHeaders().getAccept().stream().anyMatch(MediaType.TEXT_HTML::isCompatibleWith);
    }

return true.

@fvanderbiest
Copy link
Member

Thanks for the report Pierre.
We'll see what can be done here.

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

No branches or pull requests

3 participants