mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-17 06:32:41 -05:00
[Feature & Proposal] Maintenance Mode #4598
Open
opened 2025-11-02 05:55:41 -06:00 by GiteaMirror
·
16 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16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0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/proposal
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#4598
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bagasme on GitHub (Jan 6, 2020).
We can schedule a maintenance window in case we perform maintenance tasks that requires taking offline Gitea instance (such as upgrading Gitea, migrating data, scaling hardware resources, and troubleshooting system issues).
Feature:
503 Service Unavailableerror code.@lunny commented on GitHub (Jan 6, 2020):
will replace #9577
@sapk commented on GitHub (Jan 6, 2020):
The subfunction for message/banner is already discussed under #2345
@bagasme commented on GitHub (Jan 7, 2020):
@sapk so #2345 is dependency of this issue?
@justusbunsi commented on GitHub (May 9, 2021):
Anyone working on this or #2345? I would like to learn Go a bit more and could try to implement this feature. It just might take a while. 😉
@sapk commented on GitHub (May 9, 2021):
I mentioned the issue #2345 to link them and if possible already take in account the broader usage of message broadcast but this can be done in second time if not possible in one time.
@justusbunsi no one opened a PR linked to those two issues so don't hesitate to start. If you have question feel free to come ask them on discord.
Since you will need to change things in frontend and backend this guide can be helpful to start: https://docs.gitea.io/en-us/hacking-on-gitea/
@justusbunsi commented on GitHub (May 29, 2021):
After some time diving into the code and inspect the admin area, I would add a maintenance mode section inside the admin dashboard below the actions section. Is this a good place to have this?
Regardless of the configuration location: As proposed above it would allow manually enabling/disabling maintenance immediately, defining a message that will be displayed at the top of each page and specifying a datetime range to schedule the maintenance. Seconds will be trimmed.
What I am currently struggling with is where to store these data.
@lunny commented on GitHub (Jun 6, 2021):
I think you could create a new table to store the message.
@wxiaoguang commented on GitHub (Apr 14, 2022):
I think it's not feasible at the moment.
(update: it could be done by using designed rules to block all writing requests, only leave a few requests open for admin login/management, but the effort paid for it seems not trivial, while the benefit is trivial)
Gitea is a single-binary app, and no cluster support at the moment. When you are
upgrading Gitea, migrating data, scaling hardware resources, and troubleshooting system issues, Gitea itself usually is not running.You could setup a nginx (or some other proxy) to do the
503response or show a banner.@lunny commented on GitHub (Apr 14, 2022):
But you can run serval instances and keep at least one running.
@wxiaoguang commented on GitHub (Apr 14, 2022):
Then, what's the benefit? The only running instance should stop all cron tasks, clear queue, stop all sessions and just tell user a 503 response code? And if you are running several Gitea instances, isn't there a nginx-like proxy before them? then why not just let the nginx return 503 .....
But the effort paid for it seems not trivial, while the benefit is trivial. And the situation might be worse for Windows SQLite users, as long as the database is in use, it could not be backuped.
@McNetic commented on GitHub (Apr 22, 2022):
I also think the feature proposal is sensible.
@m-ueberall commented on GitHub (May 31, 2022):
To extend on the above: A maintenance mode does not (should not) necessarily require shutting down the service (read: terminate all processes, including the main one). And that's exactly what makes a huge difference w.r.t. monitoring/watchdog solutions that are "usually eager to restart one or more instances (in a cluster) if Gitea isn't up and running".
If a maintenance mode basically signals "I'm alive, restriction of certain functionality atm is intentional" instead – regardless of what will be restricted –, this does not require additional, solution-specific checks/rules on the outside.
Also, with respect to the third item above (backup purposes), switching one or more (connected) Gitea instances into maintenance mode in a defined manner (e.g. by flushing certain caches and/or waiting for some operations to finish in case of a specified "grace period") allows for external scripts/events to make use of a defined state for a series of actions that aren't/cannot be considered atomic together.
One example would be a backup consisting of dumping the database and creating a snapshot of the file system using two different tools (say,
zfs [snapshot …]followed bymariabackup [--backup …]) basically at any given point in time after/before toggling maintenance mode–usually for a mere couple of seconds as "post-processing" said backup/copy does not require any restrictions anymore.@silentcodeg commented on GitHub (May 31, 2022):
Here are links to what prompted to re-open this feature proposal today:
@mutech commented on GitHub (Feb 24, 2023):
What does gitea do when shutdown while a big commit or some other long running action operating on either the DB or the git repository is ongoing?
I would assume that gitea itself just shuts down and the components (git library, postgres et.al) take care of the details.
That's what I do in my homelab. I just take disk backups while the system is running. While this is a bit careless and harsh, it works surprisingly well. Over the years I only once had an inconsistent backup and I could live with loosing some wiki edits or issue updates.
However, in an environment where a lot of people work concurrently, I don't do that, not wanting to look stupid in front of everybody. But if then gitea does not gracefully stop ongoing processes or wait for their completion, being careful doesn't buy me much. If on the other hand gitea handles this properly, all that needed to be done would be to not accept new connections or api calls with side effects. The hard part seems to be the handling of ongoing operations and that in turn does not feel like an optional feature.
Extending proper handling to a maintenance mode in which interactive users get some nice piece of UI does not seem to be especially hard in comparison to what's needed to defend against data corruption or inconsistent states between DB and repo.
Why is this feature so difficult to provide?
@garymoon commented on GitHub (Feb 27, 2023):
Not speaking on behalf of the maintains of course, just as an infrastructure engineer.
If you want your application to stay responsive during maintenance, "connection draining" (or similar) is feature you should reasonably expect of your load balancer, not your application. If high availability is necessary, you'll have multiple frontends running, and at restart/replacement time the load balancer will stop sending new requests to the frontend pending restart/replacement, but maintain existing connections until they close or a hard timeout is reached.
For example: Swarm will do this via
deploy.update_config, and AWS will do it via ELB connection draining. Unfortunately in Nginx this functionality is gated behind the very expensive Nginx Plus subscription.If you want a specific error page for a maintenance page style functionality, you'd simply set a custom static page to serve for a 503 error. For example: Nginx will let you set an error page via
error_page. The page could be changed for scheduled maintainenance vs and unexpected outage by changing the location of the page and reloading Nginx (systemctl reload nginxornginx -s reload) which is a downtime-free operation.@lunny commented on GitHub (Sep 11, 2023):
When before backuping Gitea instance, Gitea instance should enter a maintenance mode to refuse data changes to reduce data loss.
To implement maintenance mode, a quick method is to can control two layers. One is for database writing, we can do something with a maintenance engine implementation to return error for all write operations.
Another is for git command, we can detect all possible write git operations and return error message about the instance is maintaining.