go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.28k stars 5.33k forks source link

Add `PROGRAM_MAY_MODIFY_SETTINGS` setting #26393

Open delvh opened 11 months ago

delvh commented 11 months ago

Problem derivation

At the moment, we always need to delegate config changes to the admins of an instance, and refuse to start otherwise. The reason for that is two-fold:

  1. A settings move might have unintended consequences, so it's better that an admin does it
  2. We don't know if we can write to the app.ini or not, i.e. Docker users and Kubernetes users like to use their app.ini read only once it is initialized.

But what if we would know if we can modify the config? Then we could automate a lot of things that are currently impossible. So, what I'm proposing is the following:

Solution

As a first step to automating config changes, we can add a PROGRAM_MAY_MODIFY_SETTINGS setting (I guess in the default section) that is true by default (the docker image and helm chart would set it to false by default). It has the following meaning:

Advantages

silverwind commented 11 months ago

Ideally I would like to see a config override table (simple key-value) being written into SQL because writing into local config will not work properly in distributed setups unless all nodes do it which then presents the problem of coordinating the nodes. It's not something one wants to get into.

Said config override table could be shown on the admin ui and admins could be requested to persist the changed settings in their config. Then, once the config table and config are equal, delete the value from the config table.

delvh commented 11 months ago

Yep, additionally, we already have always write access to the database. That's another benefit in this case.