[PR #3754] [MERGED] Enhance healthcheck for database connectivity #17070

Closed
opened 2025-11-02 12:25:36 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3754
Author: @neezer
Created: 4/3/2018
Status: Merged
Merged: 4/4/2018
Merged by: @lunny

Base: masterHead: master


📝 Commits (1)

  • 5570ce7 Enhance healthcheck for database connectivity

📊 Changes

1 file changed (+4 additions, -1 deletions)

View changed files

📝 models/models.go (+4 -1)

📄 Description

Modify the call to ping the database to fail gracefully if the database has not yet been configured by the end user, such as after a clean install. This allows /healthcheck to return a 200 with a modified status message instead of causing a PANIC.


I ran into this issue when trying to install Gitea on Kubernetes in Google Cloud Platform. The root path / returns a 302 redirect to /install, but GCP Health Checks treat anything that's not a 200 as a "unhealthy" status. I also saw that Macaron provides a /healthcheck endpoint and that y'all were pinging the database when hitting it, but this causes a PANIC if the database has not yet been configured. This PR guards against that and returns 200 with a different error message:

  • Database connection: database not configured

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3754 **Author:** [@neezer](https://github.com/neezer) **Created:** 4/3/2018 **Status:** ✅ Merged **Merged:** 4/4/2018 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`5570ce7`](https://github.com/go-gitea/gitea/commit/5570ce7f399827eb2d59a8edea71cfb3dcb4c6de) Enhance healthcheck for database connectivity ### 📊 Changes **1 file changed** (+4 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `models/models.go` (+4 -1) </details> ### 📄 Description Modify the call to ping the database to fail gracefully if the database has not yet been configured by the end user, such as after a clean install. This allows /healthcheck to return a 200 with a modified status message instead of causing a PANIC. --- I ran into this issue when trying to install Gitea on Kubernetes in Google Cloud Platform. The root path `/` returns a 302 redirect to `/install`, but GCP Health Checks treat anything that's not a 200 as a "unhealthy" status. I also saw that Macaron provides a `/healthcheck` endpoint and that y'all were pinging the database when hitting it, but this causes a PANIC if the database has not yet been configured. This PR guards against that and returns 200 with a different error message: > * Database connection: database not configured --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:25:36 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17070