1

I'm trying to use a log filter on client.log to evaluate if Chef runs succeeded.

In the normal course of a Chef run, my recipe requests a reboot.

Chef logs:

  FATAL: Chef::Exceptions::Reboot: Rebooting server at a recipe's request. 

Why does Chef throw an error with a normal reboot request? How can I prevent this error from being logged.

My reboot request looks like

reboot "my_reboot" do
  action :reboot_now
  reason 'There is a pending reboot.'
  only_if { reboot_pending? }
  delay_mins 0.5
end
Jeff
  • 35,755
  • 15
  • 108
  • 220
  • Apart from above logs, there would be bit more which can state the reason. please try to run in debug to check reason or provide a bit more log on this. – Mrigesh Priyadarshi Aug 20 '16 at 20:48

1 Answers1

0

Because we want to avoid running anything further in the Chef converge and the easiest way to do that is to raise an exception.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • 2
    exceptions should be exceptional. If the log isn't a reliable source of determining whether the last chef run(s) returned an error, what is? – Jeff Aug 20 '16 at 22:43
  • 2
    It's a weird special case because Ruby doesn't have any other non-local code execution flow construct that would work well in this case. You'll just have to add a filter for it. Such are the realities of building software in an imperfect world :) – coderanger Aug 21 '16 at 05:24