From: Krisztian Lengyel Date: Tue, 14 May 2019 19:22:52 +0000 (-0400) Subject: Make own CPU allocation for CaaS default CPU pool X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Finfra-ansible.git;a=commitdiff_plain;h=86e9056a7ee8ec41856edb13b72273951edb3d87 Make own CPU allocation for CaaS default CPU pool This change separates CaaS default allocation from platform allocation by making an own CPU allocation for it. Change-Id: I443e8df96b27d9734ae01f5638ec2360987c9803 Signed-off-by: Krisztian Lengyel --- diff --git a/roles/allocate_cpu_cores/defaults/main.yml b/roles/allocate_cpu_cores/defaults/main.yml index 0a43c76..bd89b92 100644 --- a/roles/allocate_cpu_cores/defaults/main.yml +++ b/roles/allocate_cpu_cores/defaults/main.yml @@ -13,7 +13,7 @@ # limitations under the License. # Number of platform CPUs to allocate per service by default. -cloud_default_platform_cpus: +platform_cpus: default: controller: own: 1 @@ -24,9 +24,9 @@ cloud_default_platform_cpus: compute: shared: 1 caas_master: - own: 2 + shared: 1 caas_worker: - own: 1 + shared: 1 single: controller: own: 1 @@ -34,9 +34,9 @@ cloud_default_platform_cpus: compute: shared: 1 caas_master: - own: 1 + shared: 1 caas_worker: - own: 1 + shared: 1 virtual: controller: shared: 2 @@ -45,15 +45,32 @@ cloud_default_platform_cpus: compute: shared: 1 caas_master: - shared: 2 + shared: 1 caas_worker: shared: 1 +caas_default_pool_cpus: + default: + caas_master: + own: 2 + caas_worker: + own: 1 + single: + caas_master: + own: 2 + caas_worker: + own: 1 + virtual: + caas_master: + own: 2 + caas_worker: + own: 1 + caas_service_profiles: - caas_master - caas_worker -allocation_fact_file: "/etc/ansible/facts.d/cloud_cpu_allocation.fact" +allocation_fact_file: "/etc/ansible/facts.d/cpu_allocation.fact" cpu_set_mapping: ovs_dpdk: @@ -64,3 +81,5 @@ cpu_set_mapping: opt: exclusive_pool_percentage caas_shared: opt: shared_pool_percentage + +caas_cpu_pool_share_default: 50 diff --git a/roles/allocate_cpu_cores/tasks/main.yml b/roles/allocate_cpu_cores/tasks/main.yml index b1c835f..4c400bc 100644 --- a/roles/allocate_cpu_cores/tasks/main.yml +++ b/roles/allocate_cpu_cores/tasks/main.yml @@ -1,5 +1,4 @@ --- - # Copyright 2019 Nokia # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,19 +16,19 @@ - name: Prepare. set_fact: - cloud_cpu_remain: [] - cloud_cpu_sets: {} + cpu_remain: [] + cpu_sets: {} - name: Get CPU topology. get_cpu_topology: - var: cloud_cpu_topology + var: cpu_topology - debug: - var: cloud_cpu_topology + var: cpu_topology - name: Make default performance profile. set_fact: perf_profile: { - platform_cpus: "{{ cloud_cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], cloud_default_platform_cpus, virtual_env, hosts | length < 2) }}" + platform_cpus: "{{ cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], platform_cpus, virtual_env, hosts | length < 2) }}" } - debug: var: perf_profile @@ -56,7 +55,7 @@ - name: Set collocated VM CPU set. set_fact: - vm_share_percent: "{{ 100 - (perf_profile['caas_cpu_pool_share'] | default(100) | int) }}" + vm_share_percent: "{{ 100 - (perf_profile['caas_cpu_pool_share'] | default(caas_cpu_pool_share_default) | int) }}" when: - "'compute' in hosts[hostname]['service_profiles']" - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) @@ -66,13 +65,22 @@ loop_control: loop_var: cpu_set with_items: - - { 'name': 'vm', 'request': "{{ cloud_cpu_topology | get_cpu_count_by_percent(vm_share_percent) }}", 'where': 'tail' } + - { 'name': 'vm', 'request': "{{ cpu_topology | get_cpu_count_by_percent(vm_share_percent) }}", 'where': 'tail' } when: - "'compute' in hosts[hostname]['service_profiles']" +- name: Make CaaS default CPU set. + include_tasks: make_cpu_sets.yaml + loop_control: + loop_var: cpu_set + with_items: + - { 'name': 'caas_default', 'request': "{{ cpu_topology | cpu_topology_defaults(hosts[hostname]['service_profiles'], caas_default_pool_cpus, virtual_env, hosts | length < 2) }}", 'where': 'tail' } + when: + - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) + - name: Calculate CaaS CPU counts set_fact: - perf_profile: "{{ perf_profile | combine({ item.key: cloud_cpu_topology | get_cpu_count_by_percent(item.value) }) }}" + perf_profile: "{{ perf_profile | combine({ item.key: cpu_topology | get_cpu_count_by_percent(item.value) }) }}" with_dict: "{{ perf_profile['caas_cpu_pools'] | default({}) }}" when: hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) @@ -89,19 +97,29 @@ - name: Make set of remaining CPUs. set_fact: - cloud_cpu_remain: "{{ cloud_cpu_remain | union(item) }}" - with_items: "{{ cloud_cpu_topology.values() }}" + cpu_remain: "{{ cpu_remain | union(item) }}" + with_items: "{{ cpu_topology.values() }}" - debug: - var: cloud_cpu_remain + var: cpu_remain + +- name: Allocate remaining CPUs to CaaS default. + set_fact: + cpu_sets: "{{ cpu_sets | combine({ 'caas_default': cpu_sets['caas_default'] | default([]) | union(cpu_remain) }) }}" + cpu_remain: [] + when: + - "cpu_remain | length > 0" + - hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) - name: Allocate remaining CPUs to platform. set_fact: - cloud_cpu_sets: "{{ cloud_cpu_sets | combine({ 'platform': cloud_cpu_sets['platform'] | default([]) | union(cloud_cpu_remain) }) }}" - cloud_cpu_remain: [] - when: "cloud_cpu_remain | length > 0" + cpu_sets: "{{ cpu_sets | combine({ 'platform': cpu_sets['platform'] | default([]) | union(cpu_remain) }) }}" + cpu_remain: [] + when: + - "cpu_remain | length > 0" + - not hosts[hostname]['service_profiles'] | intersect(caas_service_profiles) - debug: - var: cloud_cpu_sets + var: cpu_sets - name: Make sure facts directory exists. file: @@ -111,7 +129,7 @@ - name: Save CPU allocation. template: - src: cloud_cpu_allocation.fact.j2 + src: cpu_allocation.fact.j2 dest: "{{ allocation_fact_file }}" register: cpu_allocation diff --git a/roles/allocate_cpu_cores/tasks/make_cpu_sets.yaml b/roles/allocate_cpu_cores/tasks/make_cpu_sets.yaml index a128fe7..b11e480 100644 --- a/roles/allocate_cpu_cores/tasks/make_cpu_sets.yaml +++ b/roles/allocate_cpu_cores/tasks/make_cpu_sets.yaml @@ -1,5 +1,17 @@ --- -# Copyright (C) 2019 Nokia +# Copyright 2019 Nokia + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. - name: Set requested CPUs. set_fact: @@ -7,21 +19,21 @@ - name: Allocate CPU set. set_fact: - allocated_cpu_set: "{{ cloud_cpu_topology | cpu_topology_alloc(cpu_request, cpu_set.where) }}" + allocated_cpu_set: "{{ cpu_topology | cpu_topology_alloc(cpu_request, cpu_set.where) }}" - name: Append allocated CPU set. set_fact: - combined_cpu_set: "{{ allocated_cpu_set | union(cloud_cpu_sets[cpu_set.name] | default([])) | sort }}" + combined_cpu_set: "{{ allocated_cpu_set | union(cpu_sets[cpu_set.name] | default([])) | sort }}" - name: Make CPU set. set_fact: - cloud_cpu_sets: "{{ cloud_cpu_sets | combine({ cpu_set.name: combined_cpu_set }) }}" - cloud_cpu_topology: "{{ cloud_cpu_topology | cpu_topology_trim(cpu_request, cpu_set.where) }}" + cpu_sets: "{{ cpu_sets | combine({ cpu_set.name: combined_cpu_set }) }}" + cpu_topology: "{{ cpu_topology | cpu_topology_trim(cpu_request, cpu_set.where) }}" - name: Show created CPU sets. debug: - var: cloud_cpu_sets + var: cpu_sets - name: Show CPU topology after sets creation. debug: - var: cloud_cpu_topology + var: cpu_topology diff --git a/roles/allocate_cpu_cores/templates/cloud_cpu_allocation.fact.j2 b/roles/allocate_cpu_cores/templates/cloud_cpu_allocation.fact.j2 deleted file mode 100644 index e7074ef..0000000 --- a/roles/allocate_cpu_cores/templates/cloud_cpu_allocation.fact.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{# Copyright (C) 2018 Nokia #} -{ -{% for s in cloud_cpu_sets %} - "{{ s }}": { - "set" : {{ cloud_cpu_sets[s] | sort }}, - "list": "{{ cloud_cpu_sets[s] | set_to_cpulist }}" - }{{ "," if not loop.last else "" }} -{% endfor %} -} diff --git a/roles/allocate_cpu_cores/templates/cpu_allocation.fact.j2 b/roles/allocate_cpu_cores/templates/cpu_allocation.fact.j2 new file mode 100644 index 0000000..ea040d4 --- /dev/null +++ b/roles/allocate_cpu_cores/templates/cpu_allocation.fact.j2 @@ -0,0 +1,23 @@ +{# +Copyright 2019 Nokia + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +#} +{ +{% for s in cpu_sets %} + "{{ s }}": { + "set" : {{ cpu_sets[s] | sort }}, + "list": "{{ cpu_sets[s] | set_to_cpulist }}" + }{{ "," if not loop.last else "" }} +{% endfor %} +} diff --git a/roles/change_kernel_cmdline/tasks/main.yml b/roles/change_kernel_cmdline/tasks/main.yml index 63e8f40..37450c9 100644 --- a/roles/change_kernel_cmdline/tasks/main.yml +++ b/roles/change_kernel_cmdline/tasks/main.yml @@ -18,7 +18,7 @@ - name: Get configuration. set_fact: perf_profile: "{{ performance_profiles[hosts[hostname]['performance_profiles'][0]] if 'performance_profiles' in hosts[hostname] else {} }}" - cpu_alloc: "{{ ansible_local.cloud_cpu_allocation | default([]) }}" + cpu_alloc: "{{ ansible_local.cpu_allocation | default([]) }}" - debug: var: perf_profile - debug: diff --git a/roles/performance_nodes/tasks/ovsdpdk.yaml b/roles/performance_nodes/tasks/ovsdpdk.yaml index ae43c56..348fd0c 100644 --- a/roles/performance_nodes/tasks/ovsdpdk.yaml +++ b/roles/performance_nodes/tasks/ovsdpdk.yaml @@ -16,8 +16,8 @@ - debug: msg: - - "DPDK cores {{ ansible_local.cloud_cpu_allocation['ovs_dpdk']['list'] }}" - - "Platform cores {{ ansible_local.cloud_cpu_allocation['platform']['list'] }}" + - "DPDK cores {{ ansible_local.cpu_allocation['ovs_dpdk']['list'] }}" + - "Platform cores {{ ansible_local.cpu_allocation['platform']['list'] }}" - "Host VPUs {{ansible_processor_vcpus}}, Processor cores {{ansible_processor_cores}}" - "Threads per core {{ansible_processor_threads_per_core}}, Sockets {{ansible_processor_count}}" @@ -42,7 +42,7 @@ script: > configure_ovsdpdk.py --cores {{ansible_processor_vcpus}} --pcore {{ansible_processor_cores}} --tcore {{ansible_processor_threads_per_core}} --sockets {{ansible_processor_count}} - --dpdkcores {{ ansible_local.cloud_cpu_allocation['ovs_dpdk']['list'] }} + --dpdkcores {{ ansible_local.cpu_allocation['ovs_dpdk']['list'] }} register: result changed_when: result.rc == 0 failed_when: result.rc == 2 diff --git a/roles/performance_nodes_post/tasks/nova.yaml b/roles/performance_nodes_post/tasks/nova.yaml index 00258c1..c245598 100644 --- a/roles/performance_nodes_post/tasks/nova.yaml +++ b/roles/performance_nodes_post/tasks/nova.yaml @@ -15,7 +15,7 @@ # limitations under the License. - name: Set vcpu_pin_set - ini_file: dest=/etc/nova/nova.conf section=DEFAULT option=vcpu_pin_set value={{ ansible_local.cloud_cpu_allocation['vm']['list'] }} backup=no + ini_file: dest=/etc/nova/nova.conf section=DEFAULT option=vcpu_pin_set value={{ ansible_local.cpu_allocation['vm']['list'] }} backup=no register: nova1_result - name: Get performance profile configuration