From 5594be3ddd49e5c090af64312083ee9f0eb14cfb Mon Sep 17 00:00:00 2001 From: Evgeniy L Date: Tue, 20 Oct 2015 14:35:38 +0300 Subject: [PATCH] Implement parallel node provisioning --- examples/provisioning/provision.py | 4 +--- examples/provisioning/provision.sh | 5 ++++- resources/dnsmasq/actions/exclude_mac_pxe.yaml | 11 +++++++++++ resources/not_provisioned_node/actions/run.sh | 2 ++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/provisioning/provision.py b/examples/provisioning/provision.py index c063b3ef..5b58830e 100755 --- a/examples/provisioning/provision.py +++ b/examples/provisioning/provision.py @@ -13,9 +13,7 @@ from solar.events.api import add_event discovery_service = 'http://0.0.0.0:8881' -# DEBUG use a single node -nodes_list = [requests.get(discovery_service).json()[0]] - +nodes_list = requests.get(discovery_service).json() # Create slave node resources node_resources = vr.create('nodes', 'templates/not_provisioned_nodes.yaml', {'nodes': nodes_list}) diff --git a/examples/provisioning/provision.sh b/examples/provisioning/provision.sh index c7265890..d923fbef 100755 --- a/examples/provisioning/provision.sh +++ b/examples/provisioning/provision.sh @@ -4,6 +4,10 @@ set -eux DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Remove generated pxe exclude files +sudo rm -f /etc/dnsmasq.d/no_pxe_*.conf +sudo service dnsmasq restart + solar resource clear_all python "${DIR}"/provision.py @@ -11,4 +15,3 @@ solar changes stage solar changes process solar orch run-once last watch --color -n1 'solar orch report last' - diff --git a/resources/dnsmasq/actions/exclude_mac_pxe.yaml b/resources/dnsmasq/actions/exclude_mac_pxe.yaml index 91b16416..65c3d1be 100644 --- a/resources/dnsmasq/actions/exclude_mac_pxe.yaml +++ b/resources/dnsmasq/actions/exclude_mac_pxe.yaml @@ -3,4 +3,15 @@ tasks: - lineinfile: create=yes dest=/etc/dnsmasq.d/no_pxe_{{exclude_mac_pxe | replace(':', '_')}}.conf line="dhcp-host={{exclude_mac_pxe}},set:nopxe" + # FIXME: currently there is no way to specify + # policy not to run several tasks in parallel, + # so when we deploy several nodes in parallel + # it causes the problems when two tasks try + # to restart supervisor at the same time, and + # fail to do it. + - command: service dnsmasq status + register: log + until: log.stdout.find('running') > -1 + retries: 5 + delay: 2 - shell: service dnsmasq restart diff --git a/resources/not_provisioned_node/actions/run.sh b/resources/not_provisioned_node/actions/run.sh index 1ea0ed55..5a937ebb 100644 --- a/resources/not_provisioned_node/actions/run.sh +++ b/resources/not_provisioned_node/actions/run.sh @@ -4,3 +4,5 @@ set -eux # Fake run action which is required in order to make # dependency `run` -> `provision` + +exit 0