You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(PUP-11428) Log that we're exiting if a daemonized agent can't get its cert
Previously the state machine printed that it was exiting to stdout, which is
fine for foreground runs. But when running daemonized, stdout is redirected to
/dev/null, so there wasn't an indication that we were exiting. Now when running
daemonized write the message to puppet's logging system, so it ends up in syslog.
Copy file name to clipboardExpand all lines: lib/puppet/ssl/state_machine.rb
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,15 @@ def to_error(message, cause)
27
27
detail.set_backtrace(cause.backtrace)
28
28
Error.new(@machine,message,detail)
29
29
end
30
+
31
+
deflog_error(message)
32
+
# When running daemonized we set stdout to /dev/null, so write to the log instead
33
+
ifPuppet[:daemonize]
34
+
Puppet.err(message)
35
+
else
36
+
$stdout.puts(message)
37
+
end
38
+
end
30
39
end
31
40
32
41
# Load existing CA certs or download them. Transition to NeedCRLs.
@@ -270,10 +279,10 @@ def initialize(machine)
270
279
defnext_state
271
280
time=@machine.waitforcert
272
281
iftime < 1
273
-
puts_("Exiting now because the waitforcert setting is set to 0.")
282
+
log_error(_("Exiting now because the waitforcert setting is set to 0."))
274
283
exit(1)
275
284
elsifTime.now.to_i > @machine.wait_deadline
276
-
puts_("Couldn't fetch certificate from CA server; you might still need to sign this agent's certificate (%{name}). Exiting now because the maxwaitforcert timeout has been exceeded.") % {name: Puppet[:certname]}
285
+
log_error(_("Couldn't fetch certificate from CA server; you might still need to sign this agent's certificate (%{name}). Exiting now because the maxwaitforcert timeout has been exceeded.") % {name: Puppet[:certname]})
277
286
exit(1)
278
287
else
279
288
Puppet.info(_("Will try again in %{time} seconds.") % {time: time})
0 commit comments