2.2 agent logging override #7525

Merged
merged 3 commits into from Jun 21, 2017

Conversation

Projects
None yet
3 participants
Owner

howbazaar commented Jun 21, 2017

Description of change

If there are many units in a model, it is not always desirable to enable debug mode for the entire model while attempting to resolve issues or work out why things aren't working. This branch introduces an agent config file option that allows overriding of the model logging config so a single agent can log at specified severity levels different to the model.

QA steps

Bootstrap a model and deploy a unit.
SSH into the unit and edit the agent.conf file to specify
LOGGING_OVERRIDE=juju=debug
In the values section.
Restart the agent
Observer the continued debug logging in juju debug-log.

Documentation changes

Probably worth adding a section to the troubleshooting section of the docs.

Please add a validation check for any agent config value supplied.

MaxSize: 300, // megabytes
MaxBackups: 2,
Compress: true,
}
+ if loggingOverride := config.Value(agent.LoggingOverride); loggingOverride != "" {
@wallyworld

wallyworld Jun 21, 2017

Owner

There's a Validate() function for agent config - can we add validation there that any supplied config parses etc

@howbazaar

howbazaar Jun 21, 2017

Owner

The rationale behind not adding the logging override to the Validate function is that it is entirely a debugging option, and any value that is set will be checked when the agent starts anyway, and if it doesn't work, an error will be omitted there. Adding another logged error seems a bit pointless.

cmd/jujud/agent/machine.go
+ loggo.DefaultContext().ResetLoggerLevels()
+ err := loggo.ConfigureLoggers(loggingOverride)
+ if err != nil {
+ logger.Errorf("setting override %v", err)
@wallyworld

wallyworld Jun 21, 2017

Owner

setting logging override

cmd/jujud/agent/unit.go
+ loggo.DefaultContext().ResetLoggerLevels()
+ err := loggo.ConfigureLoggers(loggingOverride)
+ if err != nil {
+ logger.Errorf("setting override %v", err)
worker/logger/logger.go
+ if logger.configOverride != "" {
+ log.Debugf("overriding model config %q with override from agent.conf %q", loggingConfig, logger.configOverride)
+ loggingConfig = logger.configOverride
+ // If we are overriding the logging config value, there is no error.
@wallyworld

wallyworld Jun 21, 2017

Owner

Why not do this block fist. Set loggingConfig to logger.configOverride and then if empty, read from api. Will be much simpler IMO.

Owner

howbazaar commented Jun 21, 2017

$$merge$$

Contributor

jujubot commented Jun 21, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit 8b36fd1 into juju:2.2 Jun 21, 2017

1 check passed

github-check-merge-juju Ran tests against PR. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details

@howbazaar howbazaar deleted the howbazaar:2.2-agent-logging-override branch Jun 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment