-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Notify about outdated settings #23203
Conversation
Additionally, fix some unexpected bugs as `mailer` didn't set a default value for some properties by accident.
|
||
// This file is the only file that should be changed frequently in this package | ||
|
||
var currentGiteaVersion = getVersion("1.19") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I don't think it's a good idea to ask maintainers to remember this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind, maybe:
- Prod mode: parse version string
- Dev mode: run
git
to describe the base tag to get the working version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate on how I get the information on what our current version is?
If I know how to do it, I can implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Released binary: there is a var containing the build version (set by Makefile from
git describe
) - Dev mode:
git describe
:
~/work/gitea$ git describe
v1.20.0-dev-52-g151d3e7832
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From #26094
The main problem of that PR is that I still haven't found out how I have to set LD_FLAGS so that the version will be updated automatically.
The version is currently set in main
Line 28 in 6aa30af
Version = "development" // program version for this build |
Line 108 in 6aa30af
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" |
To use it elsewhere you'll need to move it to a non-main package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is especially that it isn't in the main package, and my attempts to convert it to modules.setting.history.currentGiteaVersion
were all fruitless endeavors thus far.
That's why this PR has moved to the back of my TODO list as I haven't found out yet what to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-X code.gitea.io/gitea/modules/setting/history.currentGiteaVersion=$(GITEA_VERSION)
should do the trick, although I'd recommend exporting the variable so we can use the same one in both places.
|
||
// Adds all previously removed settings | ||
// It should declare all breaking configuration changes in chronological order to ensure a monotone increasing error log | ||
func init() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these information will be displayed before setting.Init ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, init
seems uncontrollable. Is the logging system ready at the moment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the logging system ready at the moment?
Yes, that's one of the reasons it is in its own package. (The other is a clear separation of what belongs to what)
The package is only loaded when PrintRemovedSettings
is called, which is exactly after the logging has been set up, and before any other processing has happened.
If we decide to drop these two trace calls, it doesn't even matter for the init
method if the other package has been loaded already or not, the log is then only needed for PrintRemovedSettings
.
So, what is the preferred course of action here?
Dropping the trace
calls, or keeping them in and relying on the logger being initialized?
Or replacing the init
with an Init
we call ourselves?
So these information will be displayed before setting.Init ?
No, it is called as soon as setting.CfgProvider
has been set, but before any other settings have been initialized.
Since there is no setting.Init
(anymore?), that's the best course of action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or replacing the
init
with anInit
we call ourselves?
I think we should make the Init
called explicitly, it makes the calling order controllable.
"code.gitea.io/gitea/modules/setting/base" | ||
) | ||
|
||
var removedSettings map[SettingsSource]map[string][]*historyEntry = make(map[SettingsSource]map[string][]*historyEntry) // ordered by old source and then by old section (for performance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really need to store this in the memory, once we release Gitea v100, it will become very big. :) I think we just need to print them in console or log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can destroy it after printing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would have guessed that the Go GC takes care of it once
PrintRemovedSettings
has been called, as that package isn't referenced from anything anymore then. - Even if the Go GC fails to do its duty, I doubt we will ever reach noticeable sizes: Let's assume one entry uses about 200 Bytes (which is already an overestimation), then we still need 5 settings for 1KB, or 5 000 settings for 1MB.
But yes, we can of course clear the map afterward manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a package is referenced once, it's always referenced, Go never de-references / unloads packages.
GC doesn't GC global variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have guessed that the Go GC takes care of it once
PrintRemovedSettings
has been called, as that package isn't referenced from anything anymore then.
- Even if the Go GC fails to do its duty, I doubt we will ever reach noticeable sizes: Let's assume one entry uses about 200 Bytes (which is already an overestimation), then we still need 5 settings for 1KB, or 5 000 settings for 1MB.
But yes, we can of course clear the map afterward manually.
Of course, I know it's small but I want to save every byte when possible.
@@ -0,0 +1,53 @@ | |||
// Copyright 2023 The Gitea Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename should not have the prefix of the package name.
If I understand correctly, this frameworks handles 1v1 mapping. Is it possible (necessary) to have these mappings?
|
* One possible workaround would be to call Regarding the other comments: I'll probably be able to take care of them later today. |
Closing as it is far too outdated by now. |
At the moment, all notifications about setting deprecations are either maintained by hand, or are not really connected to the original version they were deprecated in anymore.
This PR cleans that up by doing the following things:
ConfigProvider
to its own packageini
→db
)modules/setting/history/setting_types.go
and define a convenience method inmodules/setting/history/exposed_api.go
. No further changes are needed.modules/setting/history/breaking_changes.go
Appearance
or as text: