From 356c19bb7b2db973e3f7356e4f70c65a18be12a6 Mon Sep 17 00:00:00 2001 From: Lukas Piwowarski Date: Wed, 18 Dec 2024 09:43:09 -0500 Subject: [PATCH] [Test-operator] Set resource limits This PR exposes the resources parameter in for all test-operator related CRs (Tempest, Tobiko, AnsibleTest, HorizonTest). This parameter can be used to specify amount of resources the test pods spawned by the test-operator should consume [1]. This commit intentionally unsets the value for Tempest test pods as the propagation of the fix for Tempest memory leak bug [1] did not reach the upstream openstack-tempest-all image yet. Once the fix is in place the default value of cifmw_test_operator_tempest_resources can be changed to {}. [1] https://github.com/openstack-k8s-operators/test-operator/pull/253 --- roles/test_operator/README.md | 4 ++++ roles/test_operator/defaults/main.yml | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/roles/test_operator/README.md b/roles/test_operator/README.md index f90451036d..ee6193308e 100644 --- a/roles/test_operator/README.md +++ b/roles/test_operator/README.md @@ -65,6 +65,7 @@ cifmw_test_operator_stages: * `cifmw_test_operator_tempest_extra_rpms`: (List) . A list of URLs that point to RPMs that should be installed before the execution of tempest. Note that this parameter has no effect when `cifmw_test_operator_tempest_external_plugin` is used. Default value: `[]` * `cifmw_test_operator_tempest_extra_configmaps_mounts`: (List) A list of configmaps that should be mounted into the tempest test pods. Default value: `[]` * `cifmw_test_operator_tempest_debug`: (Bool) Run Tempest in debug mode, it keeps the operator pod sleeping infinity (it must only set to `true`only for debugging purposes). Default value: `false` +* `cifmw_test_operator_tempest_resources`: (Dict) A dictionary that specifies resources (cpu, memory) for the test pods. When untouched it clears the default values set on the test-operator side. This means that the tempest test pods run with unspecified resource limits. Default value: `{requests: {}, limits: {}}` * `cifmw_tempest_tempestconf_config`: Deprecated, please use `cifmw_test_operator_tempest_tempestconf_config` instead * `cifmw_test_operator_tempest_tempestconf_config`: (Dict) This parameter can be used to customize the execution of the `discover-tempest-config` run. Please consult the test-operator documentation. For example, to pass a custom configuration for `tempest.conf`, use the `overrides` section: ``` @@ -118,6 +119,7 @@ Default value: {} * `cifmw_test_operator_tobiko_debug`: (Bool) Run Tobiko in debug mode, it keeps the operator pod sleeping infinity (it must only set to `true`only for debugging purposes). Default value: `false` * `cifmw_test_operator_tobiko_network_attachments`: (List) List of network attachment definitions to attach to the tobiko pods spawned by test-operator. Default value: `[]`. * `cifmw_test_operator_tobiko_workflow`: (List) Definition of a Tobiko workflow that consists of multiple steps. Each step can contain all values from Spec section of [Tobiko CR](https://openstack-k8s-operators.github.io/test-operator/crds.html#tobiko-custom-resource). +* `cifmw_test_operator_tobiko_resources`: (Dict) A dictionary that specifies resources (cpu, memory) for the test pods. When kept untouched it defaults to the resource limits specified on the test-operator side. Default value: `{}` * `cifmw_test_operator_tobiko_config`: (Dict) Definition of Tobiko CRD instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html#tobiko-custom-resource)). Default value: ``` apiVersion: test.openstack.org/v1beta1 @@ -164,6 +166,7 @@ Default value: {} * `cifmw_test_operator_ansibletest_debug`: (Bool) Run ansible playbook with -vvvv. Default value: `false` * `cifmw_test_operator_ansibletest_workflow`: (List) A parameter that contains a workflow definition. Default value: `[]` * `cifmw_test_operator_ansibletest_extra_configmaps_mounts`: (List) Extra configmaps for mounting in the pod. Default value: `[]` +* `cifmw_test_operator_ansibletest_resources`: (Dict) A dictionary that specifies resources (cpu, memory) for the test pods. When kept untouched it defaults to the resource limits specified on the test-operator side. Default value: `{}` * `cifmw_test_operator_ansibletest_config`: Definition of AnsibleTest CRD instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html)). Default value: ``` apiVersion: test.openstack.org/v1beta1 @@ -209,6 +212,7 @@ Default value: {} * `cifmw_test_operator_horizontest_flavor_name`: (String) The name of the OpenStack flavor to create for Horizon tests. Default value: `m1.tiny` * `cifmw_test_operator_horizontest_logs_directory_name`: (String) The name of the directory to store test logs. Default value: `horizon` * `cifmw_test_operator_horizontest_horizon_test_dir`: (String) The directory path for Horizon tests. Default value: `/var/lib/horizontest` +* `cifmw_test_operator_horizontest_resources`: (Dict) A dictionary that specifies resources (cpu, memory) for the test pods. When kept untouched it defaults to the resource limits specified on the test-operator side. Default value: `{}` * `cifmw_test_operator_horizontest_config`: (Dict) Definition of HorizonTest CR instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html#horizontest-custom-resource)). Default value: ``` apiVersion: test.openstack.org/v1beta1 diff --git a/roles/test_operator/defaults/main.yml b/roles/test_operator/defaults/main.yml index 2b2beb88d0..cc90811b44 100644 --- a/roles/test_operator/defaults/main.yml +++ b/roles/test_operator/defaults/main.yml @@ -60,6 +60,13 @@ cifmw_test_operator_tempest_workflow: [] cifmw_test_operator_tempest_cleanup: false cifmw_test_operator_tempest_tempestconf_config: "{{ cifmw_tempest_tempestconf_config }}" +# TODO: The default value of this parameter should be changed to {} once this fix +# for tempest reaches the upstream build of the openstack-tempest-all image: +# https://review.opendev.org/c/openstack/tempest/+/934980 +cifmw_test_operator_tempest_resources: + requests: {} + limits: {} + # Enabling SRBAC by default, in jobs where this does not make sense should be turned off explicitly # # auth.tempest_roles is set to an empty value because otherwise @@ -123,6 +130,7 @@ cifmw_test_operator_tempest_config: tolerations: "{{ cifmw_test_operator_tolerations | default(omit) }}" nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}" extraConfigmapsMounts: "{{ stage_vars_dict.cifmw_test_operator_tempest_extra_configmaps_mounts | default(omit) }}" + resources: "{{ stage_vars_dict.cifmw_test_operator_tempest_resources }}" tempestRun: includeList: | {{ stage_vars_dict.cifmw_test_operator_tempest_include_list | default('') }} @@ -158,6 +166,7 @@ cifmw_test_operator_tobiko_ssh_keysize: "{{ cifmw_ssh_keysize | default(521) }}" cifmw_test_operator_tobiko_debug: false cifmw_test_operator_tobiko_network_attachments: [] cifmw_test_operator_tobiko_workflow: [] +cifmw_test_operator_tobiko_resources: {} cifmw_test_operator_tobiko_config: apiVersion: test.openstack.org/v1beta1 kind: Tobiko @@ -177,6 +186,7 @@ cifmw_test_operator_tobiko_config: nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}" debug: "{{ stage_vars_dict.cifmw_test_operator_tobiko_debug }}" networkAttachments: "{{ stage_vars_dict.cifmw_test_operator_tobiko_network_attachments }}" + resources: "{{ stage_vars_dict.cifmw_test_operator_tobiko_resources }}" # preventCreate: preventCreate is generated by the test_operator role based on the value of stage_vars_dict.cifmw_test_operator_tobiko_prevent_create # numProcesses: numProcesses is generated by the test_operator role based on the value of stage_vars_dict.cifmw_test_operator_tobiko_num_processes # privateKey: privateKey is automatically by the test_operator role @@ -204,6 +214,7 @@ cifmw_test_operator_ansibletest_openstack_config_secret: "openstack-config-secre cifmw_test_operator_ansibletest_debug: false cifmw_test_operator_ansibletest_workflow: [] cifmw_test_operator_ansibletest_extra_configmaps_mounts: [] +cifmw_test_operator_ansibletest_resources: {} cifmw_test_operator_ansibletest_config: apiVersion: test.openstack.org/v1beta1 kind: AnsibleTest @@ -228,6 +239,7 @@ cifmw_test_operator_ansibletest_config: openStackConfigSecret: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_openstack_config_secret }}" workflow: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_workflow }}" debug: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_debug }}" + resources: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_resources }}" # Section 5: horizontest parameters - used when run_test_fw is 'horizontest' cifmw_test_operator_horizontest_name: "horizontest-tests" @@ -249,6 +261,7 @@ cifmw_test_operator_horizontest_password: "horizontest" cifmw_test_operator_horizontest_flavor_name: "m1.tiny" cifmw_test_operator_horizontest_logs_directory_name: "horizon" cifmw_test_operator_horizontest_horizon_test_dir: "/var/lib/horizontest" +cifmw_test_operator_horizontest_resources: {} cifmw_test_operator_horizontest_config: apiVersion: test.openstack.org/v1beta1 kind: HorizonTest @@ -273,3 +286,4 @@ cifmw_test_operator_horizontest_config: flavorName: "{{ stage_vars_dict.cifmw_test_operator_horizontest_flavor_name }}" logsDirectoryName: "{{ stage_vars_dict.cifmw_test_operator_horizontest_logs_directory_name }}" horizonTestDir: "{{ stage_vars_dict.cifmw_test_operator_horizontest_horizon_test_dir }}" + resources: "{{ stage_vars_dict.cifmw_test_operator_horizontest_resources }}"