Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Feb 24, 2025

The deprecated setting fallback logic should be removed once the target version is reached. A warning will be displayed if the old configuration items are still present.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 24, 2025
@lunny lunny added this to the 1.24.0 milestone Feb 24, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Feb 24, 2025
@lunny lunny force-pushed the lunny/remove_fallback_keep_warning branch from 844adda to 564c670 Compare February 24, 2025 19:55
@lunny lunny changed the title Remove all the deprecated setting fall backs because it reached the expected version and put a warning there Remove all the deprecated setting fallback logic because it reached the target version and put a warning there if old configuration are still present Feb 24, 2025
Comment on lines 336 to 338
func deprecatedSettingWarning(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
if rootCfg.Section(oldSection).HasKey(oldKey) {
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` presents, please use `[%s].%s` instead because this fallback has been removed in %s", oldSection, oldKey, newSection, newKey, version)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func deprecatedSettingWarning(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
if rootCfg.Section(oldSection).HasKey(oldKey) {
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` presents, please use `[%s].%s` instead because this fallback has been removed in %s", oldSection, oldKey, newSection, newKey, version)
// deprecatedSettingWarning is a warning about a setting that has already been removed, giving the user a last chance to fix their app.ini
func deprecatedSettingWarning(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
if rootCfg.Section(oldSection).HasKey(oldKey) {
LogStartupProblem(1, log.ERROR, "Deprecation: config option `[%s].%s` is still present, please use `[%s].%s` instead. This fallback has been removed in %s", oldSection, oldKey, newSection, newKey, version)

Copy link
Member Author

Choose a reason for hiding this comment

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

// make linter happy when there is no deprecated setting at the moment
var _ = deprecatedSetting

func deprecatedSettingWarning(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) {
Copy link
Member

Choose a reason for hiding this comment

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

removedSetting?

Copy link
Member Author

Choose a reason for hiding this comment

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

5ab0de8

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 24, 2025
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

I think I have told you not only one time: such change breaks existing users.

Especially for some settings like LFS_CONTENT_PATH: the OLD DATA IS LOST!!! because you won't read the old config anymore.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 25, 2025
@lunny
Copy link
Member Author

lunny commented Feb 25, 2025

I think I have told you not only one time: such change breaks existing users.

Especially for some settings like LFS_CONTENT_PATH: the OLD DATA IS LOST!!! because you won't read the old config anymore.

Do you have any idea how to improve it? Fatal if there is an old configuration? Or leave the fallback code forever?

@wxiaoguang
Copy link
Contributor

Do you have any idea how to improve it? Fatal if there is an old configuration? Or leave the fallback code forever?

Some approaches in my mind:

  1. Make Gitea fully manage the config file and migrate the config content.
    • It might not work well with helmchart (just a guess).
  2. Collect all deprecated config options and only "Fatal" once to output them together.
    • There should be only one "Fatal" even if there are many deprecated config options.
    • Otherwise if there are quite a few deprecated options, site admin would get stuck in "fatal -> modify config -> fatal -> modify config -> fatal" loop.

Comment on lines +34 to +41
if strings.Contains(host, ":") {
addr, port, err := net.SplitHostPort(host)
assert.NoError(t, err)
sec.NewKey("SMTP_ADDR", addr)
sec.NewKey("SMTP_PORT", port)
} else {
sec.NewKey("SMTP_ADDR", host)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the tests are changed? Does it break?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test was test the legacy configurations. Now the fallback code was removed. So the test was changed to test the new configurations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I guess the test cases should be updated, but not change the config code here, unless you could clarify the config test code must be changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to your change, the "HOST" key is gone, why you use the trick here to test the non-existing "HOST" config option?

@lunny
Copy link
Member Author

lunny commented Mar 1, 2025

Both a system failure and a critical issue can impact the admin user. To ensure awareness, we should implement a mandatory warning page that appears on every login, requiring the admin to acknowledge it before proceeding. Close this PR and leave an new issue for the future action.

@lunny lunny closed this Mar 1, 2025
@GiteaBot GiteaBot removed this from the 1.24.0 milestone Mar 1, 2025
@go-gitea go-gitea locked as resolved and limited conversation to collaborators May 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants