Skip to content

Commit

Permalink
Merge branch 'main' into edpm_nvidia_mdev_prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
sbauza authored Oct 8, 2024
2 parents 23da455 + eb3e0d9 commit 4ed6560
Show file tree
Hide file tree
Showing 75 changed files with 729 additions and 188 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ new_role: create_new_role role_molecule ## Create a new Ansible role and related
##@ Setup steps
.PHONY: setup_tests
setup_tests: ## Setup the environment
bash scripts/setup_env
bash scripts/setup_env 2>&1 | tee $(LOG_DIR)/setup_env.log

.PHONY: setup_molecule
setup_molecule: setup_tests ## Setup molecule environment
bash scripts/setup_molecule
bash scripts/setup_molecule 2>&1 | tee $(LOG_DIR)/setup_molecule.log

##@ General testing
.PHONY: tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
~/test-python/bin/ansible-playbook {{ ansible_user_dir }}/networking_mapper.yml
-i {{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml
-e @scenarios/centos-9/base.yml
-e cifmw_networking_mapper_ifaces_info_path=/etc/ci/env/interfaces-info.yml
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
{% if nodepool is defined %}
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/nodepool_params.yml"
Expand Down
10 changes: 9 additions & 1 deletion ci/playbooks/molecule-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
---
- name: "Run ci/playbooks/molecule-test.yml"
hosts: "{{ cifmw_zuul_target_host | default('controller') }}"
gather_facts: true
gather_facts: false
tasks:
- name: Gather required facts
ansible.builtin.setup:
gather_subset:
- "!all"
- "!min"
- "user_dir"
- "env"

- name: Load environment var if instructed to
when:
- cifmw_reproducer_molecule_env_file is defined
Expand Down
2 changes: 1 addition & 1 deletion ci/playbooks/pre-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

- name: Download and extract golang
ansible.builtin.unarchive:
src: "https://golang.org/dl/go{{ go_version | default('1.20.14') }}.linux-amd64.tar.gz"
src: "https://golang.org/dl/go{{ go_version | default('1.21.13') }}.linux-amd64.tar.gz"
dest: "/usr/local"
remote_src: true
extra_opts:
Expand Down
18 changes: 18 additions & 0 deletions deploy-ocp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@
ansible.builtin.import_role:
name: "libvirt_manager"
tasks_from: "deploy_layout.yml"

# Run from the hypervisor
- name: Ensure OCP cluster is stable
vars:
_auth_path: >-
{{
(
cifmw_devscripts_repo_dir,
'ocp',
cifmw_devscripts_config.cluster_name,
'auth'
) | ansible.builtin.path_join
}}
cifmw_openshift_adm_op: "stable"
cifmw_openshift_kubeconfig: >-
{{ (_auth_path, 'kubeconfig') | ansible.builtin.path_join }}
ansible.builtin.include_role:
name: openshift_adm
1 change: 1 addition & 0 deletions docs/dictionary/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ tempestconf
testcases
testenv
timestamper
timesync
tldca
tls
tmp
Expand Down
2 changes: 2 additions & 0 deletions docs/source/usage/01_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ are shared among multiple roles:
- `cifmw_nolog`: (Bool) Toggle `no_log` value for selected tasks. Defaults to `true` (hiding those logs by default).
- `cifmw_parent_scenario`: (String or List(String)) path to existing scenario/parameter file to inherit from.
- `cifmw_configure_switches`: (Bool) Specifies whether switches should be configured. Computes in `reproducer.yml` playbook. Defaults to `false`.
- `cifmw_use_ocp_overlay`: (Boolean) Specifies whether OCP nodes deployed via devscripts should use overlay images. Using overlay images speeds up the redeployment when using the reproducer role locally but in CI each job is cleaned up and redeployed. Creating the overlay image takes time so should be disabled when not used. Defaults to `true`.
- `cifmw_crc_default_network`: (String) name of the untagged network used to address DNS on the crc node. Default is `default`.
- `cifmw_run_operators_compliance_scans`: (Bool) Specifies whether to run operator compliance scans. Defaults to `false`.
- `cifmw_run_compute_compliance_scans`: (Bool) Specifies whether to run compliance scans on the first compute. Defaults to `false`.
- `cifmw_run_id`: (String) CI Framework run identifier. This is used in libvirt_manager, to add some uniqueness to some types of virtual machines (anything that's not OCP, CRC nor controller).
If not set, the Framework will generate a random string for you, and store it on the target host, in `{{ cifmw_basedir }}/artifacts/run-id`
- `cifmw_deploy_architecture_args`: (String) additional args and parameters to pass to the deploy-architecture script. Default is `''`.

```{admonition} Words of caution
:class: danger
Expand Down
41 changes: 41 additions & 0 deletions docs/toolbelt-catalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Catalog entry for Backstage [backstage.io]

apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: ci-framework
title: ci-framework
description: |
CI Framework - used for CI, QE and Devs to run OSP 18+ jobs in a converged way
annotations:
github.com/project-slug: openstack-k8s-operators/ci-framework
feedback/type: JIRA
feedback/host: https://issues.redhat.com
jira/project-key: OSPRH
links:
- title: docs
url: https://ci-framework.readthedocs.io/en/latest/
icon: docs
- title: code
url: https://github.com/openstack-k8s-operators/ci-framework
icon: github
- title: "#osp-podified-ci-support"
url: https://app.slack.com/client/E030G10V24F/C03MD4LG22Z
icon: chat
tags:
- testing
- test-execution
- test-framework
- test-management
- test-reporting
- provisioning
- python
- openstack
- openshift
- cloud
- continuous-integration
namespace: quality-community
spec:
type: tool
owner: group:redhat/openstack-k8s-operators-ci
lifecycle: production
4 changes: 4 additions & 0 deletions hooks/playbooks/fetch_compute_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
- name: Load parameters
ansible.builtin.include_vars:
dir: "{{ item }}"
ignore_unknown_extensions: true
extensions:
- yaml
- yml
loop:
- "{{ cifmw_basedir }}/artifacts/parameters"
- "/etc/ci/env"
Expand Down
15 changes: 12 additions & 3 deletions playbooks/ceph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

- name: Distribute SSH keypair to target nodes
tags: admin
hosts: "{{ cifmw_ceph_target | default('computes') }}"
hosts: "{{ cifmw_ceph_target | default('computes') }}"
gather_facts: false
become: true
vars:
Expand Down Expand Up @@ -265,7 +265,12 @@
gather_facts: false
vars:
_target_hosts: "{{ groups[cifmw_ceph_target | default('computes')] | default([]) }}"
ansible_ssh_private_key_file: "{{ lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY') }}"
_target: "{{ _target_hosts | first }}"
ansible_ssh_private_key_file: >-
{{
hostvars[_target]['ansible_ssh_private_key_file'] |
default(lookup('env', 'ANSIBLE_SSH_PRIVATE_KEY'))
}}
cifmw_cephadm_spec_ansible_host: /tmp/ceph_spec.yml
cifmw_cephadm_bootstrap_conf: /tmp/initial_ceph.conf
cifmw_ceph_client_vars: /tmp/ceph_client.yml
Expand All @@ -279,6 +284,7 @@
pg_autoscale_mode: true
target_size_ratio: 0.3
application: rbd
trash_purge_enabled: true
- name: backups
pg_autoscale_mode: true
target_size_ratio: 0.1
Expand Down Expand Up @@ -402,7 +408,7 @@
tasks_from: rgw
vars:
# cifmw_cephadm_vip is computed or passed as an override via -e @extra.yml
cifmw_cephadm_rgw_vip: "{{ cifmw_cephadm_vip }}/{{ cidr }}"
cifmw_cephadm_rgw_vip: "{{ cifmw_cephadm_vip }}"

- name: Configure Monitoring Stack
when: cifmw_ceph_daemons_layout.dashboard_enabled | default(false) | bool
Expand Down Expand Up @@ -449,6 +455,9 @@
ansible.builtin.import_role:
name: cifmw_cephadm
tasks_from: post
vars:
cifmw_cephadm_dashboard_crt: "{{ cifmw_cephadm_certificate }}"
cifmw_cephadm_dashboard_key: "{{ cifmw_cephadm_key }}"

- name: Render Ceph client configuration
tags: client
Expand Down
13 changes: 8 additions & 5 deletions plugins/module_utils/net_map/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@


class NetworkMappingError(Exception, ansible_encoding.RawConvertibleObject):
def __init__(self, message) -> None:
def __init__(self, message, **kwargs) -> None:
super().__init__(message)
self.message = message
self.details = kwargs

def to_raw(self) -> typing.Dict[str, typing.Any]:
return ansible_encoding.decode_ansible_raw(vars(self))
Expand All @@ -22,17 +23,18 @@ def __init__(
invalid_value=None,
parent_name=None,
parent_type=None,
**kwargs,
) -> None:
super().__init__(message)
super().__init__(message, **kwargs)
self.field = field
self.invalid_value = invalid_value
self.parent_name = parent_name
self.parent_type = parent_type


class HostNetworkRangeCollisionValidationError(NetworkMappingValidationError):
def __init__(self, message, range_1=None, range_2=None) -> None:
super().__init__(message)
def __init__(self, message, range_1=None, range_2=None, **kwargs) -> None:
super().__init__(message, **kwargs)
self.range_1 = range_1
self.range_2 = range_2

Expand All @@ -48,8 +50,9 @@ def __init__(
invalid_value=None,
parent_name=None,
parent_type=None,
**kwargs,
) -> None:
super().__init__(message)
super().__init__(message, **kwargs)
self.field = field
self.invalid_value = invalid_value
self.parent_name = parent_name
Expand Down
4 changes: 4 additions & 0 deletions plugins/module_utils/net_map/networking_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def _validate_fields_one_of(
parent_type: str = None,
alone_field: str = None,
mandatory: bool = False,
**kwargs,
) -> bool:
fields_present = any(
field_name in raw_definition.keys() for field_name in fields_list
Expand All @@ -183,6 +184,7 @@ def _validate_fields_one_of(
f"at least one of {mandatory_fields} must be provided",
parent_name=parent_name,
parent_type=parent_type,
**kwargs,
)
if alone_field and alone_field in raw_definition:
rest = [
Expand All @@ -198,6 +200,7 @@ def _validate_fields_one_of(
invalid_value=raw_definition[alone_field],
parent_name=parent_name,
parent_type=parent_type,
**kwargs,
)

return True
Expand Down Expand Up @@ -2100,6 +2103,7 @@ def __parse_raw_net_ranges(
parent_name=self.__group_name,
parent_type=self.__OBJECT_TYPE_NAME,
alone_field=self.__FIELD_NETWORK_RANGE,
network_name=network_definition.name,
)
if not ranges_present:
return None, None
Expand Down
2 changes: 1 addition & 1 deletion reproducer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
poll: 20
delegate_to: controller-0
ansible.builtin.command:
cmd: "/home/zuul/deploy-architecture.sh"
cmd: "/home/zuul/deploy-architecture.sh {{ cifmw_deploy_architecture_args | default('') }}"
2 changes: 2 additions & 0 deletions roles/ci_gen_kustomize_values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ with a message.
* `ci_gen_kustomize_fetch_ocp_state`: (Boolean) If true it enables generating CI templates based on the OCP state. Defaults to `true`.
* `cifmw_ci_gen_kustomize_values_storage_class_prefix`: (String) Prefix for `storageClass` in generated values.yaml files. Defaults to `"lvms-"` only if `cifmw_use_lvms` is True, otherwise it defaults to `""`. The prefix is prepended to the `cifmw_ci_gen_kustomize_values_storage_class`. It is not recommended to override this value, instead set `cifmw_use_lvms` True or False.
* `cifmw_ci_gen_kustomize_values_storage_class`: (String) Value for `storageClass` in generated values.yaml files. Defaults to `"lvms-local-storage"` only if `cifmw_use_lvms` is True, otherwise it defaults to `"local-storage"`.
* `cifmw_ci_gen_kustomize_values_remove_keys_expressions`: (List) Remove keys matching the regular expressions from source ConfigMaps (values.yaml).
Defaults to `["^nodes$", "^node(_[0-9]+)?$"]`.

### Specific parameters for edpm-values
This configMap needs some more parameters in order to properly override the `architecture` provided one.
Expand Down
3 changes: 3 additions & 0 deletions roles/ci_gen_kustomize_values/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ cifmw_ci_gen_kustomize_values_storage_class_prefix: "{{ 'lvms-' if cifmw_use_lvm
cifmw_ci_gen_kustomize_values_storage_class: "{{ cifmw_ci_gen_kustomize_values_storage_class_prefix }}local-storage"

cifmw_ci_gen_kustomize_values_primary_ip_version: 4
cifmw_ci_gen_kustomize_values_remove_keys_expressions:
- ^nodes$
- ^node(_[0-9]+)?$

# Those parameter must be set if you want to edit an "edpm-values"
# cifmw_ci_gen_kustomize_values_ssh_authorizedkeys
Expand Down
5 changes: 3 additions & 2 deletions roles/ci_gen_kustomize_values/tasks/generate_snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
_cifmw_gen_kustomize_values_base_cm_content: >-
{{
_config_map_content |
ansible.utils.remove_keys(target=['^nodes?(_[0-9]+)?$'],
matching_parameter='regex')
ansible.utils.remove_keys(
target=cifmw_ci_gen_kustomize_values_remove_keys_expressions,
matching_parameter='regex')
}}
cacheable: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
lb_tools={}) %}
data:
{% for host in cifmw_networking_env_definition.instances.keys() -%}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() -%}
{% if host is match('^(ocp|crc).*') %}
node_{{ ns.ocp_index }}:
name: {{ cifmw_networking_env_definition.instances[host]['hostname'] }}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() %}
{% set ns.interfaces = ns.interfaces |
combine({network.network_name: (network.parent_interface |
default(network.interface_name)
)
},
recursive=true) -%}
{% endfor -%}
{% if host is match('^(ocp|crc).*') %}
node_{{ ns.ocp_index }}:
name: {{ cifmw_networking_env_definition.instances[host]['hostname'] }}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() %}
recursive=true) %}
{{ network.network_name }}_ip: {{ network.ip_v4 }}
{% endfor %}
{% set node_net_orig_content = original_content.data.bgp['net-attach-def']['node' ~ ns.ocp_index] %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@
data:
{% for host in cifmw_networking_env_definition.instances.keys() -%}
{% set hostname = cifmw_networking_env_definition.instances[host]['hostname'] %}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() -%}
{% if 'worker-3' != hostname %}
{% if host is match('^(ocp|crc).*') %}
node_{{ ns.ocp_index }}:
name: {{ hostname }}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() %}
{% set ns.interfaces = ns.interfaces |
combine({network.network_name: (network.parent_interface |
default(network.interface_name)
)
},
recursive=true) -%}
{% endif %}
{% endfor -%}
{% if host is match('^(ocp|crc).*') %}
node_{{ ns.ocp_index }}:
name: {{ hostname }}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() %}
recursive=true) %}
{{ network.network_name }}_ip: {{ network.ip_v4 }}
{% if 'worker-3' == hostname and 'ctlplane' == network.network_name %}
base_if: {{ network.interface_name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ data:
{% for net in cifmw_networking_env_definition.instances[instance].networks.keys() %}
- name: {{ net }}
subnetName: subnet1
fixedIP: {{ cifmw_networking_env_definition.instances[instance].networks[net][_ipv.ip_vX] }}
{% if net is match('ctlplane') %}
defaultRoute: true
fixedIP: {{ cifmw_networking_env_definition.instances[instance].networks.ctlplane[_ipv.ip_vX] }}
{% endif %}
{% endfor %}
{% endfor %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
lb_tools={}) %}
data:
{% for host in cifmw_networking_env_definition.instances.keys() -%}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() -%}
{% set ns.interfaces = ns.interfaces |
combine({network.network_name: (network.parent_interface |
default(network.interface_name)
)
},
recursive=true) -%}
{% endfor -%}
{% if host is match('^(ocp|crc).*') %}
node_{{ ns.ocp_index }}:
{% set ns.ocp_index = ns.ocp_index+1 %}
name: {{ cifmw_networking_env_definition.instances[host]['hostname'] }}
{% for network in cifmw_networking_env_definition.instances[host]['networks'].values() %}
{% set ns.interfaces = ns.interfaces |
combine({network.network_name: (network.parent_interface |
default(network.interface_name)
)
},
recursive=true) %}
{{ network.network_name }}_ip: {{ network[_ipv.ip_vX] }}
{% endfor %}
{% endif %}
Expand Down
Loading

0 comments on commit 4ed6560

Please sign in to comment.