Skip to content
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

Merged
merged 13 commits into from
Jun 16, 2016
Merged

Feature: increase/decrease logging level without restarting #748

merged 13 commits into from
Jun 16, 2016

Conversation

HuKeping
Copy link
Contributor

@HuKeping HuKeping commented May 14, 2016

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

@docker-jenkins
Copy link

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)
Copy link
Contributor Author

@HuKeping HuKeping May 14, 2016

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.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

@HuKeping HuKeping changed the title [WIP] Feature: hot configuration reload for notary server Feature: hot configuration reload for notary server May 19, 2016
@cyli
Copy link
Contributor

cyli commented May 20, 2016

jenkins, test this please

@NathanMcCauley
Copy link
Contributor

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add.

@HuKeping
Copy link
Contributor Author

@NathanMcCauley Will add the docs later

@cyli
Copy link
Contributor

cyli commented May 23, 2016

jenkins, test this please

@HuKeping
Copy link
Contributor Author

docs and test ready @NathanMcCauley

@HuKeping
Copy link
Contributor Author

HuKeping commented Jun 3, 2016

ping ...

@riyazdf
Copy link
Contributor

riyazdf commented Jun 6, 2016

jenkins, test this please.


v := viper.New()
utils.SetupViper(v, "envPrefix")
//v.SetConfigType("json")
Copy link
Contributor

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?

@HuKeping HuKeping changed the title Feature: hot configuration reload for notary server Feature: increase/decrease logging level without restarting Jun 11, 2016
@HuKeping
Copy link
Contributor Author

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:
Copy link
Contributor

@riyazdf riyazdf Jun 13, 2016

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."

@riyazdf
Copy link
Contributor

riyazdf commented Jun 13, 2016

jenkins, test this please

@@ -225,6 +228,7 @@ func parseServerConfig(configFilePath string, hRegister healthRegister) (context
}

ctx := context.Background()
ctx = context.WithValue(ctx, "config", config)
Copy link
Contributor

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

Copy link
Contributor Author

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.

@HuKeping
Copy link
Contributor Author

updated.

@HuKeping
Copy link
Contributor Author

Some error on CI system

@HuKeping
Copy link
Contributor Author

rebased

@cyli
Copy link
Contributor

cyli commented Jun 15, 2016

jenkins, test this please

HuKeping added 13 commits June 15, 2016 18:42
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>
Fix typo , update docs and remove some unused code.

From riyazdf's comment.

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>
@HuKeping
Copy link
Contributor Author

ping ...

@cyli
Copy link
Contributor

cyli commented Jun 16, 2016

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!

@riyazdf
Copy link
Contributor

riyazdf commented Jun 16, 2016

@HuKeping thank you for reworking this PR (code and docs) and your patience! LGTM 👍

@riyazdf riyazdf merged commit d1e910b into notaryproject:master Jun 16, 2016
@HuKeping HuKeping deleted the feature-hot-reload branch June 17, 2016 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants