From 9b00f4b02a9c986eccef1ce38017d2d61785fab3 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sun, 23 May 2021 22:05:03 +0200 Subject: [PATCH] copr-be: centralize aws/spot/hypervisor config in inventory --- inventory/group_vars/copr_aws | 12 +++++++++ inventory/group_vars/copr_dev_aws | 12 +++++++++ roles/copr/backend/tasks/main.yml | 25 +++++++++++++++++++ roles/copr/backend/templates/copr-be.conf.j2 | 9 ++++--- .../backend/templates/resalloc/pools.yaml | 20 +++++++-------- 5 files changed, 64 insertions(+), 14 deletions(-) diff --git a/inventory/group_vars/copr_aws b/inventory/group_vars/copr_aws index 206d284752..6bc9e1f4a6 100644 --- a/inventory/group_vars/copr_aws +++ b/inventory/group_vars/copr_aws @@ -38,4 +38,16 @@ builders: s390x: [0,0,0] aarch64: [0,2,2] + #x86_hypervisor_01: + # x86_64: [2,1,1] + + x86_hypervisor_02: + x86_64: [20,3,20] + + x86_hypervisor_03: + x86_64: [20,3,20] + + x86_hypervisor_04: + x86_64: [20,3,20] + rpm_vendor_copr_name: Fedora Copr diff --git a/inventory/group_vars/copr_dev_aws b/inventory/group_vars/copr_dev_aws index a5b2ebd7bf..611759b6d3 100644 --- a/inventory/group_vars/copr_dev_aws +++ b/inventory/group_vars/copr_dev_aws @@ -39,4 +39,16 @@ builders: s390x: [1,0,0] aarch64: [5,2,2] + #x86_hypervisor_01: + # x86_64: [2,1,1] + + x86_hypervisor_02: + x86_64: [2,1,1] + + x86_hypervisor_03: + x86_64: [2,1,1] + + x86_hypervisor_04: + x86_64: [2,1,1] + rpm_vendor_copr_name: Fedora Copr (devel) diff --git a/roles/copr/backend/tasks/main.yml b/roles/copr/backend/tasks/main.yml index 83b2387030..7805c42b22 100644 --- a/roles/copr/backend/tasks/main.yml +++ b/roles/copr/backend/tasks/main.yml @@ -162,6 +162,31 @@ # - library # tags: # - provision_config +# +- name: calculate the maximum resalloc workers per architecture + set_fact: "max_{{ item }}_workers={{ builders | community.general.json_query('*.'+item+'[0]') | sum() }}" + with_items: + - x86_64 + - armhfp + - s390x + - aarch64 + tags: + - provision_config + +- name: calculate max number of workers + set_fact: "max_workers={{ max_x86_64_workers|int + max_armhfp_workers|int + max_s390x_workers|int + max_aarch64_workers|int }}" + tags: + - provision_config + +- name: print max arch workers + debug: "var=max_{{ item }}_workers" + with_items: + - x86_64 + - armhfp + - s390x + - aarch64 + tags: + - provision_config - name: resalloc import_tasks: resalloc.yml diff --git a/roles/copr/backend/templates/copr-be.conf.j2 b/roles/copr/backend/templates/copr-be.conf.j2 index ba67a34907..06986e33ac 100644 --- a/roles/copr/backend/templates/copr-be.conf.j2 +++ b/roles/copr/backend/templates/copr-be.conf.j2 @@ -38,13 +38,14 @@ sleeptime=20 # This option basically controls the amount of RAM allocated for # processing builds on copr backend, and how many resalloc tickets can # be taken at the same time. -builds_max_workers={{ builders.aws.x86_64[0] + builders.aws.aarch64[0] + builders.aws.armhfp[0] }} +builds_max_workers={{ max_workers }} # Maximum number of concurrently running tasks per architecture. builds_max_workers_arch= - x86_64={{ builders.aws.x86_64[0] }}, - aarch64={{ builders.aws.aarch64[0]}}, - armhfp={{ builders.aws.armhfp[0] }} + x86_64={{ max_x86_64_workers }}, + aarch64={{ max_aarch64_workers }}, + armhfp={{ max_armhfp_workers }}, + s390x={{ max_s390x_workers }} # Maximum number of concurrently running tasks per project owner. {% if env == 'production' %} diff --git a/roles/copr/backend/templates/resalloc/pools.yaml b/roles/copr/backend/templates/resalloc/pools.yaml index ea0d4986cd..f9b1e36ab1 100644 --- a/roles/copr/backend/templates/resalloc/pools.yaml +++ b/roles/copr/backend/templates/resalloc/pools.yaml @@ -49,17 +49,12 @@ aws_aarch64_{% if spot %}spot{% else %}normal{% endif %}_{% if devel %}dev{% els {% endmacro %} # x86_64 hypervisors -{% for hv in ["02", "03", "04"] %} +{% for hv in ["01", "02", "03", "04"] %} +{% if "x86_hypervisor_" + hv in builders %} copr_hv_x86_64_{{ hv }}_{% if devel %}dev{% else %}prod{% endif %}: -{% if devel %} - max: 3 - max_starting: 1 - max_prealloc: 1 -{% else %} - max: 20 - max_starting: 4 - max_prealloc: 20 -{% endif %} + max: {{ builders["x86_hypervisor_" + hv]["x86_64"][0] }} + max_starting: {{ builders["x86_hypervisor_" + hv]["x86_64"][1] }} + max_prealloc: {{ builders["x86_hypervisor_" + hv]["x86_64"][2] }} tags: - copr_builder - arch_x86_64 @@ -85,6 +80,11 @@ copr_hv_x86_64_{{ hv }}_{% if devel %}dev{% else %}prod{% endif %}: reuse_opportunity_time: 180 reuse_max_count: 8 reuse_max_time: 1800 +{% else %} +# +# x86_hypervisor_{{ hv }} not configured in group_vars +# +{% endif %} {% endfor %} {% macro hw_aarch64(id, inst, max, max_starting, max_prealloc) %}