-
Notifications
You must be signed in to change notification settings - Fork 512
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
Feature: increase/decrease logging level without restarting #748
Conversation
Can one of the admins verify this patch? |
switch sig { | ||
case syscall.SIGUSR1: | ||
if err := utils.AdjustLogLevel(true); err != nil { | ||
fmt.Println("Increase log level failed, will use the old one, error: ", err) |
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.
Why using fmt.Print
not logrus
here and below is because it will not log out anything if the log level is too low, Panic
for example and we can't just use logrus.Panicf()
for it will terminate the whole process.
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.
Sounds good, could we also print the log level we're reverting back to? For example: Attempt to increase log level failed, will remain at %s level, error:
(with the old level filling that string). logrus has a GetLevel
function we can 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.
Good point
jenkins, test this please |
This functionality should be covered somewhere in the docs, so folks can know about it when reading through documentation. |
// reloadConfig was designed to do all the dirty work that needed to reload | ||
// the config for notary-server and make the entrance-ReloadConfiguration() | ||
// for hot configuration reload do some generic things. | ||
func reloadConfig(sig os.Signal, configFile string, oldConfig *viper.Viper, envPrefix string) { |
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.
This function doesn't seem to have any test coverage. @HuKeping could you add some tests for 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.
Will add.
@NathanMcCauley Will add the docs later |
jenkins, test this please |
docs and test ready @NathanMcCauley |
ping ... |
jenkins, test this please. |
|
||
v := viper.New() | ||
utils.SetupViper(v, "envPrefix") | ||
//v.SetConfigType("json") |
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.
can we delete this line?
Drop the code for reloading the whole config file, this patch set plans only to support increase/decrease logging level. |
@@ -359,6 +361,29 @@ Example: | |||
</tr> | |||
</table> | |||
|
|||
## Hot logging level reload | |||
We don't support to completely reload the whole configuration yet at present. What we support for now is: |
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.
Can we change this first sentence to: "We don't support completely reloading notary configuration files yet at present."
jenkins, test this please |
@@ -225,6 +228,7 @@ func parseServerConfig(configFilePath string, hRegister healthRegister) (context | |||
} | |||
|
|||
ctx := context.Background() | |||
ctx = context.WithValue(ctx, "config", config) |
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 don't think we need this anymore for the current functionality
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.
Oh I missed this one, will clean it up.
updated. |
Some error on CI system |
rebased |
jenkins, test this please |
Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
…o handle Signed-off-by: Hu Keping <hukeping@huawei.com>
… server This patch will allow people to: - use SIGUSR1 to increment the logging level - use SIGUSR2 to decrement the logging level And it will allow the logging level to be turned up or down as much as desired by sending the appropriate signal multiple times. Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
This patch will allow people to use SIGHUP to tell notary server to reload the configuration file. For now it only supports to reload the logging level. Signed-off-by: Hu Keping <hukeping@huawei.com>
From NathanMcCauley's review Signed-off-by: Hu Keping <hukeping@huawei.com>
Signed-off-by: Hu Keping <hukeping@huawei.com>
From riyazdf's comments. Signed-off-by: Hu Keping <hukeping@huawei.com>
After disscussing with the team, we all agreed that it might not make sense to completely reload the whole config file yet at present. Instead, a graceful shutdown would be a better choice. Signed-off-by: Hu Keping <hukeping@huawei.com>
Otherwise it will not print anything until the flag for flush is coming. Signed-off-by: Hu Keping <hukeping@huawei.com>
About how to increase/decrease logging level via system signal. Signed-off-by: Hu Keping <hukeping@huawei.com>
ping ... |
Sorry for the lack of response @HuKeping. We are all prepping for DockerCon. :) This LGTM, thank you so much for your incredible patience and all your hard work on this feature! |
@HuKeping thank you for reworking this PR (code and docs) and your patience! LGTM 👍 |
Part of #633
As discussed with the team of notary, it might not make sense to completely reload the configuration yet.
With this patch set, we can send SIGUSR1/SIGUSR2 to increase/decrease the logging level of notary-server.
Signed-off-by: Hu Keping hukeping@huawei.com