Improve syslog defaults. (#1932)
Under the new defaults, if the syslog section is missing, we'll use the default config that we use in prod: no logs to stdout, INFO and below to syslog. This allows us to remove the syslog section from prod configs, and potentially move it to individual service configs in the future. * Improve syslog defaults. * Add stdout logging for purger test. * Use plain int for sysloglevel. * Fix JSON syntax * Fix syslog config for expired-authz-purger. https://github.com/letsencrypt/boulder/pull/1932
This commit is contained in:
parent
6bd97b2a6b
commit
4283fb5dd4
|
|
@ -448,8 +448,8 @@ type GoogleSafeBrowsingConfig struct {
|
|||
|
||||
// SyslogConfig defines the config for syslogging.
|
||||
type SyslogConfig struct {
|
||||
StdoutLevel *int
|
||||
SyslogLevel *int
|
||||
StdoutLevel int
|
||||
SyslogLevel int
|
||||
}
|
||||
|
||||
// StatsdConfig defines the config for Statsd.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
"expiredAuthzPurger": {
|
||||
"syslog": {
|
||||
"stdoutLevel": 6
|
||||
},
|
||||
"dbConnectFile": "test/secrets/purger_dburl",
|
||||
"maxDBConns": 10,
|
||||
"gracePeriod": "168h",
|
||||
|
|
|
|||
|
|
@ -120,8 +120,7 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
seven := 7
|
||||
_, log := cmd.StatsAndLogging(cmd.StatsdConfig{}, cmd.SyslogConfig{StdoutLevel: &seven})
|
||||
_, log := cmd.StatsAndLogging(cmd.StatsdConfig{}, cmd.SyslogConfig{StdoutLevel: 7})
|
||||
|
||||
configData, err := ioutil.ReadFile(*configFile)
|
||||
cmd.FailOnError(err, fmt.Sprintf("Reading %s", *configFile))
|
||||
|
|
|
|||
14
cmd/shell.go
14
cmd/shell.go
|
|
@ -185,18 +185,14 @@ func StatsAndLogging(statConf StatsdConfig, logConf SyslogConfig) (metrics.Statt
|
|||
syslogger, err := syslog.Dial(
|
||||
"",
|
||||
"",
|
||||
syslog.LOG_INFO|syslog.LOG_LOCAL0, // default, overridden by log calls
|
||||
syslog.LOG_INFO, // default, not actually used
|
||||
tag)
|
||||
FailOnError(err, "Could not connect to Syslog")
|
||||
stdoutLoglevel := int(syslog.LOG_DEBUG)
|
||||
if logConf.StdoutLevel != nil {
|
||||
stdoutLoglevel = *logConf.StdoutLevel
|
||||
syslogLevel := int(syslog.LOG_INFO)
|
||||
if logConf.SyslogLevel != 0 {
|
||||
syslogLevel = logConf.SyslogLevel
|
||||
}
|
||||
syslogLogLevel := int(syslog.LOG_DEBUG)
|
||||
if logConf.SyslogLevel != nil {
|
||||
syslogLogLevel = *logConf.SyslogLevel
|
||||
}
|
||||
logger, err := blog.New(syslogger, stdoutLoglevel, syslogLogLevel)
|
||||
logger, err := blog.New(syslogger, logConf.StdoutLevel, syslogLevel)
|
||||
FailOnError(err, "Could not connect to Syslog")
|
||||
|
||||
_ = blog.Set(logger)
|
||||
|
|
|
|||
|
|
@ -248,34 +248,22 @@ def run_expired_authz_purger_test():
|
|||
subprocess.check_output('''node test.js --email %s --domains %s --abort-step %s''' %
|
||||
("purger@test.com", "eap-test.com", "startChallenge"), shell=True)
|
||||
|
||||
def expect(target_time, num):
|
||||
expected_output = 'Deleted a total of %d expired pending authorizations' % num
|
||||
try:
|
||||
out = get_future_output("./bin/expired-authz-purger --config cmd/expired-authz-purger/config.json --yes", target_time, cwd="../..")
|
||||
if expected_output not in out:
|
||||
print("\nOutput from expired-authz-purger did not contain '%s'. Actual: %s"
|
||||
% (expected_output, out))
|
||||
die(ExitStatus.NodeFailure)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("\nFailed to run authz purger: %s" % e)
|
||||
die(ExitStatus.NodeFailure)
|
||||
|
||||
now = datetime.datetime.utcnow()
|
||||
after_grace_period = now + datetime.timedelta(days=+14, minutes=+3)
|
||||
|
||||
target_time = now
|
||||
expected_output = 'Deleted a total of 0 expired pending authorizations'
|
||||
try:
|
||||
out = get_future_output("./bin/expired-authz-purger --config cmd/expired-authz-purger/config.json --yes", target_time, cwd="../..")
|
||||
|
||||
print(out)
|
||||
if expected_output not in out:
|
||||
print("\nBad output from authz purger")
|
||||
die(ExitStatus.NodeFailure)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("\nFailed to run authz purger: %s" % e)
|
||||
die(ExitStatus.NodeFailure)
|
||||
|
||||
target_time = after_grace_period
|
||||
expected_output = 'Deleted a total of 1 expired pending authorizations'
|
||||
try:
|
||||
out = get_future_output("./bin/expired-authz-purger --config cmd/expired-authz-purger/config.json --yes", target_time, cwd="../..")
|
||||
|
||||
print(out)
|
||||
if expected_output not in out:
|
||||
print("\nBad output from authz purger")
|
||||
die(ExitStatus.NodeFailure)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("\nFailed to run authz purger: %s" % e)
|
||||
die(ExitStatus.NodeFailure)
|
||||
expect(now, 0)
|
||||
expect(after_grace_period, 1)
|
||||
|
||||
@atexit.register
|
||||
def cleanup():
|
||||
|
|
|
|||
Loading…
Reference in New Issue