chef / chef-apply

The ad-hoc execution tool for the Chef ecosystem.
https://www.chef.sh/
Apache License 2.0
14 stars 14 forks source link

`chef-run` Concurrency Option #158

Open jonsmorrow opened 4 years ago

jonsmorrow commented 4 years ago

As a chef-run operator,

I would like to be able to control the concurrency of my chef-runs,

So that I can better orchestrate my adhoc tasks ..

For example, let’s assume I have defined a range of hosts (tomcat-prod[1:10]) I want chef-run against to patch Java and restart Tomcat .. My recipe looks something like this:


package 'java-1.8.0-openjdk-devel' do

action :upgrade

notifies :restart, 'service[tomcat]', :delayed

end

service 'tomcat' do

action :nothing

end

The problem I am having is that they will all upgrade and restart at the same time, which means downtime .. I would like to have the opportunity to use a --concurrency option that would limit how many hosts are being worked on at the same time << very similar to the knife ssh option .. If possible, I would like to also be able to define a percentage value that would calculate how many hosts exists, and then based on my percentage value, work on the allowed amount ..

Example commands are:


# ASSUME 10 hosts total

# only work on 5 nodes at a time

chef-run tomcat-prod[1:10] upgrade_and_restart.rb --concurrency 5 ..

# only work on 50% of nodes at a time (i.e. 5 in in this example)

chef-run tomcat-prod[1:10] upgrade_and_restart.rb --concurrency '50%' ..

Before you say: “Greg, you already know there are 10 hosts, so just define 5 and be done with it” .. This is true, BUT, I have another idea submitted were we allow hosts pattern matching using regex, and if that comes true, then the chef-run operator may not know how many hosts exist and so we should allow them to deal in percentages vs hard numbers ..

Thanks and let me know if you have questions .. Here is a link to how Ansible is doing it using serial :: https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_delegation.html#rolling-update-batch-size

Aha! Link: https://chef.aha.io/epics/WS-E-28