From 8b44c718b4c5baeee1e970e0ccf6a811ef358580 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:18:42 +0100 Subject: [PATCH 1/6] Use round-robin scheduling instead of all-on-one --- ansible/action_plugins/tenks_schedule.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ansible/action_plugins/tenks_schedule.py b/ansible/action_plugins/tenks_schedule.py index 275f8ba..62973dd 100644 --- a/ansible/action_plugins/tenks_schedule.py +++ b/ansible/action_plugins/tenks_schedule.py @@ -43,11 +43,14 @@ class ActionModule(ActionBase): hostname of the hypervisor to which they are scheduled. """ result = super(ActionModule, self).run(tmp, task_vars) + # Initialise our return dict. + result['result'] = {} del tmp # tmp no longer has any effect self._validate_vars(task_vars) nodes = [] idx = 0 + hypervisor_names = task_vars['hypervisor_vars'].keys() for typ, cnt in six.iteritems(task_vars['specs']): for _ in six.moves.range(cnt): node = deepcopy(task_vars['node_types'][typ]) @@ -59,12 +62,15 @@ class ActionModule(ActionBase): vol['name'] = "%s%d" % (task_vars['vol_name_prefix'], vol_idx) nodes.append(node) + # Perform round-robin scheduling with node index modulo number + # of hypervisors. + hyp_name = hypervisor_names[idx % len(hypervisor_names)] + try: + result['result'][hyp_name].append(node) + except KeyError: + # This hypervisor doesn't yet have any scheduled nodes. + result['result'][hyp_name] = [node] idx += 1 - - # TODO(w-miller): currently we just arbitrarily schedule all nodes to - # the first hypervisor. Improve this algorithm to make it more - # sophisticated. - result['result'] = {task_vars['hypervisor_vars'].keys()[0]: nodes} return result def _validate_vars(self, task_vars): From af98a202499cd159783dc97258b5175e0b1cd4ea Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:21:29 +0100 Subject: [PATCH 2/6] Fix upper constraints typo --- ansible/deploy_hosts.yml | 3 ++- ansible/roles/virtualbmc-daemon/tasks/main.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ansible/deploy_hosts.yml b/ansible/deploy_hosts.yml index a8cbbdf..a5e59ed 100644 --- a/ansible/deploy_hosts.yml +++ b/ansible/deploy_hosts.yml @@ -24,4 +24,5 @@ name: virtualbmc-daemon vars: vbmcd_virtualenv_path: "{{ virtualenv_path }}" - vbmcd_python_upper_contraints_url: "{{ python_upper_constraints_url }}" + vbmcd_python_upper_constraints_url: >- + {{ python_upper_constraints_url }} diff --git a/ansible/roles/virtualbmc-daemon/tasks/main.yml b/ansible/roles/virtualbmc-daemon/tasks/main.yml index c850a50..937d90f 100644 --- a/ansible/roles/virtualbmc-daemon/tasks/main.yml +++ b/ansible/roles/virtualbmc-daemon/tasks/main.yml @@ -10,7 +10,7 @@ pip: requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}" extra_args: >- - -c {{ vbmcd_python_upper_contraints_url }} + -c {{ vbmcd_python_upper_constraints_url }} virtualenv: "{{ vbmcd_virtualenv_path }}" - name: Ensure Virtual BMC systemd service is configured From 768af20e849b5f738a1051e4184577d1f64a0ca2 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:22:06 +0100 Subject: [PATCH 3/6] Move pip settings to group_vars/all We need to use pip on localhost as well as on hypervisors, for Ironic enrolment. --- ansible/group_vars/all | 9 +++++++++ ansible/group_vars/hypervisors | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 ansible/group_vars/all diff --git a/ansible/group_vars/all b/ansible/group_vars/all new file mode 100644 index 0000000..6eee2da --- /dev/null +++ b/ansible/group_vars/all @@ -0,0 +1,9 @@ +--- +# Path to virtualenv used to install Python requirements. If a virtualenv does +# not exist at this location, one will be created. +virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}" + +# The URL of the upper constraints file to pass to pip when installing Python +# packages. +python_upper_constraints_url: >- + https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt diff --git a/ansible/group_vars/hypervisors b/ansible/group_vars/hypervisors index 4b7eb96..dc6dcad 100644 --- a/ansible/group_vars/hypervisors +++ b/ansible/group_vars/hypervisors @@ -6,15 +6,6 @@ physnet_mappings: {} system_requirements: - python-virtualenv -# Path to virtualenv used to install Python requirements. If a virtualenv does -# not exist at this location, one will be created. -virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}" - -# The URL of the upper constraints file to pass to pip when installing Python -# packages. -python_upper_constraints_url: >- - https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt - # Naming scheme for bridges created by tenks for physical networks is # {{ bridge_prefix + i }}, where `i` is the index of the physical network in # physnet_mappings (sorted alphabetically by key). From 3066438a7fc10fffd2e6d3a666cb805daf607092 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:23:00 +0100 Subject: [PATCH 4/6] Use full path for ip command --- ansible/physical_network.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ansible/physical_network.yml b/ansible/physical_network.yml index f806a55..9957bbb 100644 --- a/ansible/physical_network.yml +++ b/ansible/physical_network.yml @@ -13,7 +13,8 @@ source_type: direct - name: Get source interface details - command: ip -details link show {{ source_interface }} + # NOTE(w-miller): The `ip` command may not be in $PATH, so use the full path. + command: /usr/sbin/ip -details link show {{ source_interface }} register: if_details changed_when: false From 9b1ad58146832e2c3576ee0b4b7f628b2ed098e8 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:23:22 +0100 Subject: [PATCH 5/6] Use become for all Open vSwitch tasks --- ansible/physical_network.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/physical_network.yml b/ansible/physical_network.yml index 9957bbb..4f30b95 100644 --- a/ansible/physical_network.yml +++ b/ansible/physical_network.yml @@ -70,6 +70,7 @@ type=patch options:peer={{ veth_prefix + tenks_bridge + veth_bridge_source_suffix }} + become: true - name: Create patch port on source bridge openvswitch_port: @@ -80,9 +81,11 @@ type=patch options:peer={{ veth_prefix + tenks_bridge + veth_bridge_ovs_suffix }} + become: true - name: Plug source interface into Tenks bridge when: source_type == 'direct' openvswitch_port: bridge: "{{ tenks_bridge }}" port: "{{ source_interface }}" + become: true From 7f21b4c8c1c377c23dfa56be30cd4bdc9a5773c3 Mon Sep 17 00:00:00 2001 From: Will Miller Date: Fri, 7 Sep 2018 13:24:01 +0100 Subject: [PATCH 6/6] Copy requirements file to remote host The pip module requires that the requirements.txt file exists on the remote host, so copy it to a temporary location. --- ansible/roles/ironic-enrolment/tasks/main.yml | 12 +++++++++++- ansible/roles/virtualbmc-daemon/tasks/main.yml | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ansible/roles/ironic-enrolment/tasks/main.yml b/ansible/roles/ironic-enrolment/tasks/main.yml index 8196d24..875f4b7 100644 --- a/ansible/roles/ironic-enrolment/tasks/main.yml +++ b/ansible/roles/ironic-enrolment/tasks/main.yml @@ -1,7 +1,17 @@ --- +# This is useful to get a uniquely generated temporary path. +- name: Create temporary file for pip requirements + tempfile: + register: req_file + +- name: Copy requirements file to temporary location + copy: + src: requirements.txt + dest: "{{ req_file.path }}" + - name: Ensure Python requirements are installed pip: - requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}" + requirements: "{{ req_file.path }}" extra_args: >- -c {{ ironic_python_upper_constraints_url }} virtualenv: "{{ ironic_virtualenv_path }}" diff --git a/ansible/roles/virtualbmc-daemon/tasks/main.yml b/ansible/roles/virtualbmc-daemon/tasks/main.yml index 937d90f..1071e17 100644 --- a/ansible/roles/virtualbmc-daemon/tasks/main.yml +++ b/ansible/roles/virtualbmc-daemon/tasks/main.yml @@ -6,9 +6,19 @@ loop: "{{ vbmcd_packages }}" become: true +# This is useful to get a uniquely generated temporary path. +- name: Create temporary file for pip requirements + tempfile: + register: req_file + +- name: Copy requirements file to temporary location + copy: + src: requirements.txt + dest: "{{ req_file.path }}" + - name: Ensure Python requirements are installed pip: - requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}" + requirements: "{{ req_file.path }}" extra_args: >- -c {{ vbmcd_python_upper_constraints_url }} virtualenv: "{{ vbmcd_virtualenv_path }}"