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

WIP: Add health endpoint #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Enrico204
Copy link
Contributor

What is the purpose of this change? What does it change?

This pull request adds an endpoint named /health. It replies with:

  • 200 OK when the repository base path is writable and there is some free space left
  • 500 Internal Server Error when either the path is not writable by rest-server, or the disk is full

This endpoint can be used to monitor the status of a rest-server daemon (for example in k8s / docker)

Was the change discussed in an issue or in the forum before?

Feature was requested and is being discussed here: #147

Checklist

  • I have enabled maintainer edits for this PR
  • I have added tests for all changes in this PR
  • I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

@Enrico204
Copy link
Contributor Author

Enrico204 commented Aug 23, 2021

I added the external library https://github.com/itchio/ox . That library contains wrappers for many Windows syscall. I used some of them to get information about the repository path write permission for current user.

I had to call a Windows API directly, however I already made a pull request to the original library to add that wrapper.

I've tested the code on Windows and Linux.

Do I need to write some tests for this? If so, do you have any suggestion? Testing permissions and free space might be difficult...

@SchoolGuy
Copy link

SchoolGuy commented Sep 15, 2024

I would like to give this PR a bump. kubelint is complaining about missing readiness probes for rest-server. And while of course workarounds can be found, I find this PR quite appealing as a proper solution.

Edit: As 80% of the work in this PR is done, I am willing to pick it up if the maintainers are signalling to get the functionality merged in the near future. I am in a quite fortunate situation that I could actually do this during my work time as we have a dedicated time budget for learning and OSS contributions.

Comment on lines +26 to +29
err := unix.Statfs(path, &stat)
if err != nil {
return 0, err
}

Choose a reason for hiding this comment

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

This check will probably report incorrect usage numbers for btrfs-based filesystems.

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.

2 participants