Skip to content

Added the /health endpoint#9239

Closed
arnaudsjs wants to merge 6 commits intomasterfrom
issue/added-health-endpoint
Closed

Added the /health endpoint#9239
arnaudsjs wants to merge 6 commits intomasterfrom
issue/added-health-endpoint

Conversation

@arnaudsjs
Copy link
Copy Markdown
Contributor

Description

The /health endpoint provides a yes/no answer on whether the server is healthy or not. It doesn't require authentication in contrast to the /serverstatus endpoint.

Part of #9061

Self Check:

  • Attached issue to pull request
  • Changelog entry
  • Type annotations are present
  • Code is clear and sufficiently documented
  • No (preventable) type errors (check using make mypy or make mypy-diff)
  • Sufficient test cases (reproduces the bug/tests the requested feature)
  • Correct, in line with design
  • End user documentation is included or an issue is created for end-user documentation
  • If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see test-fixes for more info)

@arnaudsjs arnaudsjs requested review from sanderr and wouterdb June 18, 2025 13:08
Comment on lines +151 to +153
if call_arguments.method_properties.function == methods_v2.health:
# For ease of use, the health endpoint should be accessible without authentication.
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the rationale for configuring this here vs in the (default) policy file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. I think you are right that it would be better to include this in the policy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Given this a second though, I am on the fence now. The idea is to use the health endpoint in the docker health check and to rely on the assumption that it doesn't require authentication. So if users remove the rule from the policy file, it will break the docker health check. We could of course document this well and provide more flexibility to the user by adding it to the policy. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You make a good argument. I was only vaguely aware of the purpose of this endpoint. In that case I think it's more a property of the system than a policy, so I think it belongs here after all.

def health() -> ReturnValue[None]:
"""
Returns a 200 response code if the server is healthy
or a 500 if the server is not healthy.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

500 Internal Server Error? That's unconventional, isn't it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

on K8S livenes probes (which are the best reference I have for this),

Any code greater than or equal to 200 and less than 400 indicates success. Any other code indicates failure.

the example there also uses 500 to indicate failure

https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't really find a clear answer on what is conventional. Some applications return 500 or 503 for not healthy. Others return a 200 and mention the status in the json body. What do you consider the conventional way?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just thought that 500 was reserved for unexpected errors. But Wouter's response and yours imply that that's a misunderstanding on my part.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not too sure either thb

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was expecting that a specific response code would exist to indicate "unhealthy", but it seems there isn't one. But there is one for "I'm a teapot" :D

@arnaudsjs arnaudsjs added the merge-tool-ready This ticket is ready to be merged in label Jun 19, 2025
@inmantaci
Copy link
Copy Markdown
Contributor

Processing this pull request

@inmantaci inmantaci removed the merge-tool-ready This ticket is ready to be merged in label Jun 19, 2025
@inmantaci
Copy link
Copy Markdown
Contributor

Failed to merge changes into iso8 due to merge conflict. Please open a pull request for these branches separately by cherry-picking the commit that was made on the branch master (git cherry-pick 6657665).

@inmantaci
Copy link
Copy Markdown
Contributor

Failed to merge changes into iso7 due to merge conflict. Please open a pull request for these branches separately by cherry-picking the commit that was made on the branch master (git cherry-pick 6657665).

@inmantaci
Copy link
Copy Markdown
Contributor

Merged into branches master in 6657665

inmantaci pushed a commit that referenced this pull request Jun 19, 2025
# Description

The `/health` endpoint provides a yes/no answer on whether the server is healthy or not. It doesn't require authentication in contrast to the /serverstatus endpoint.

Part of #9061

# Self Check:

- [x] Attached issue to pull request
- [x] Changelog entry
- [x] Type annotations are present
- [x] Code is clear and sufficiently documented
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] Sufficient test cases (reproduces the bug/tests the requested feature)
- [x] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation
- [ ] ~~If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)~~
@inmantaci
Copy link
Copy Markdown
Contributor

Not closing this pull request due to previously commented issues for some of the destination branches. Please open a separate pull request for those branches by cherry-picking the relevant commit. You can safely close this pull request and delete the source branch.

@inmantaci
Copy link
Copy Markdown
Contributor

This branch was not deleted as it seems to still be in use.

@arnaudsjs arnaudsjs closed this Jun 19, 2025
@arnaudsjs arnaudsjs deleted the issue/added-health-endpoint branch June 19, 2025 09:43
This was referenced Jun 19, 2025
inmantaci pushed a commit that referenced this pull request Jun 19, 2025
# Description

**This PR just adds a dummy changelog entry. We are not going to add the health endpoint in iso7, because iso7 is missing the capability for a slice to report its status. It's also not required because the iso7 docker image doesn't have a health check either. Parent PR #9239

The `/health` endpoint provides a yes/no answer on whether the server is healthy or not. It doesn't require authentication in contrast to the /serverstatus endpoint.

Part of #9061

# Self Check:

- [x] Attached issue to pull request
- [x] Changelog entry
- [x] Type annotations are present
- [x] Code is clear and sufficiently documented
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] Sufficient test cases (reproduces the bug/tests the requested feature)
- [x] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation
- [ ] ~~If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)~~
inmantaci pushed a commit that referenced this pull request Jun 19, 2025
# Description

**Same PR as #9239 but applied on the iso8 branch due to a merge conflict.**

The `/health` endpoint provides a yes/no answer on whether the server is healthy or not. It doesn't require authentication in contrast to the /serverstatus endpoint.

Part of #9061

# Self Check:

- [x] Attached issue to pull request
- [x] Changelog entry
- [x] Type annotations are present
- [x] Code is clear and sufficiently documented
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] Sufficient test cases (reproduces the bug/tests the requested feature)
- [x] Correct, in line with design
- [ ] End user documentation is included or an issue is created for end-user documentation
- [ ] ~~If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)~~
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.

4 participants