Kitchen Can Reboot and Keep On Converging!
Alright everyone, this is a biggie… Test-Kitchen can now deal with reboots (when initiated from chef-client).
There are three new settings on the provisioner:
-
retry_on_exit_code
- which takes an array of exit codes that can indicate that kitchen should retry the converge command. Defaults to an empty array. -
max_retries
- number of times to retry the converge before passing along the failed status. Defaults to 1. -
wait_for_retry
- number of seconds to wait between converge attempts. Defaults to 30.
An example using the chef_zero
provisioner (and Chef Client 12.11 or newer with the standardized exit codes) would be
provisioner:
name: chef_zero
require_chef_omnibus: 12.11 # need the RFC 062 exit codes
retry_on_exit_code:
- 35 # 35 is the exit code signaling that the node is rebooting
max_retries: 1
client_rb:
exit_status: :enabled # Opt-in to the standardized exit codes
client_fork: false # Forked instances don't return the real exit code
One note on linux nodes, the shutdown command blocks (as opposed to the windows variant which registers the reboot and returns right away), so once the timeout period passes, chef-client and the node are in a race to see who can exit/shutdown first - so you may or may not get the exit code out of linux instances. In that case, you can add 1 to the retry_on_exit_code
array and that should catch both cases.
v1.10.0 (2016-06-16)
Implemented enhancements:
- Retry
Kitchen::Provisioner\#run\_command
after allowed exit codes #1055 (smurawski) - Add fallback support for
policyfile
for compat with the older policyfile_zero #1053 (coderanger)