Skip to content

Commit

Permalink
Merge branch 'openstack-k8s-operators:main' into edpm_nvidia_mdev_pre…
Browse files Browse the repository at this point in the history
…pare
  • Loading branch information
sbauza authored Oct 2, 2024
2 parents 6e9daa6 + d1b1e62 commit fb1a4c5
Show file tree
Hide file tree
Showing 53 changed files with 600 additions and 85 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
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
13 changes: 11 additions & 2 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 @@ -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('') }}"
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
2 changes: 2 additions & 0 deletions roles/cifmw_cephadm/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ cifmw_cephadm_update_log_commands:
# Get last cephadm logs in case of failure
- type: "mod_cephadm"
cmd: "log last cephadm"
cifmw_cephadm_wait_for_dashboard_retries: 10
cifmw_cephadm_wait_for_dashboard_delay: 20
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
ansible.builtin.command: |
{{ cifmw_cephadm_ceph_cli }} config set \
mgr mgr/dashboard/{{ current_mgr }}/server_addr \
{{ hostvars[item][all_addresses] | ansible.utils.ipaddr(cifmw_cephadm_rgw_network) | first }}
{{ hostvars[item][all_addresses] | ansible.utils.ipaddr(cifmw_cephadm_monitoring_network) | first }}
become: true
36 changes: 34 additions & 2 deletions roles/cifmw_cephadm/tasks/dashboard/validation.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
---
# Copyright 2024 Red Hat, Inc.
# All Rights Reserved.
#
# 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: Update urischeme based on cert/key
ansible.builtin.set_fact:
cifmw_cephadm_urischeme_dashboard: "https"
when:
- cifmw_cephadm_dashboard_crt | default("") | length > 0
- cifmw_cephadm_dashboard_key | default("") | length > 0

- name: Validate connection to dashboard service
ansible.builtin.get_url:
url: "http://{{ grafana_server_addr }}:{{ cifmw_cephadm_dashboard_port }}"
url: "{{ cifmw_cephadm_urischeme_dashboard | default('http') }}://{{ grafana_server_addr }}:{{ cifmw_cephadm_dashboard_port }}"
dest: "/tmp/dash_response"
validate_certs: false
register: dashboard_response
failed_when: dashboard_response.failed == true
until: dashboard_response.failed == false
retries: "{{ cifmw_cephadm_wait_for_dashboard_retries }}"
delay: "{{ cifmw_cephadm_wait_for_dashboard_delay }}"


- name: Check http response code from dashboard service with login
ansible.builtin.get_url:
url: "http://{{ grafana_server_addr }}:{{ cifmw_cephadm_dashboard_port }}"
url: "{{ cifmw_cephadm_urischeme_dashboard | default('http') }}://{{ grafana_server_addr }}:{{ cifmw_cephadm_dashboard_port }}"
dest: "/tmp/dash_http_response"
validate_certs: false
username: admin
password: admin
register: dashboard_resp
failed_when: dashboard_resp.status_code != 200
until: dashboard_resp.status_code == 200
retries: "{{ cifmw_cephadm_wait_for_dashboard_retries }}"
delay: "{{ cifmw_cephadm_wait_for_dashboard_delay }}"
12 changes: 7 additions & 5 deletions roles/cifmw_cephadm/tasks/pools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@

- name: Configure the RBD trash purge scheduler
when:
- cifmw_enabled_services | default([]) | intersect(['cinder_volume'])
- cifmw_cephadm_enable_trash_scheduler | default(false)
- cifmw_cephadm_pools is defined
- cifmw_cephadm_pools | length > 0
block:
- name: Get the RBD ceph_cli
ansible.builtin.include_tasks: ceph_cli.yml
vars:
ceph_command: rbd

- name: Set trash interval
when: item.trash_purge_enabled | default(false)
ansible.builtin.command:
cmd: |
{{ cifmw_cephadm_ceph_cli }} trash purge schedule add \
{{ cifmw_cephadm_rbd_trash_interval | default(15) }} --pool {{ item }}
cmd: >-
{{ cifmw_cephadm_ceph_cli }} trash purge schedule add
{{ cifmw_cephadm_rbd_trash_interval | default(15) }} --pool {{ item.name }}
changed_when: false
become: true
loop: "{{ [ cinder_pool.name | default('volumes') ] + cinder_pool.cinder_extra_pools | default([]) }}"
loop: "{{ cifmw_cephadm_pools | default([]) }}"
6 changes: 3 additions & 3 deletions roles/cifmw_cephadm/templates/ceph_monitoring_stack.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ placement:
- {{ _hosts[0] }}
count: 1
networks:
- {{ cifmw_cephadm_rgw_network }}
- {{ cifmw_cephadm_monitoring_network }}
---
service_type: prometheus
service_id: prometheus
Expand All @@ -21,7 +21,7 @@ placement:
- {{ _hosts[0] }}
count: 1
networks:
- {{ cifmw_cephadm_rgw_network }}
- {{ cifmw_cephadm_monitoring_network }}
---
service_type: alertmanager
service_id: alertmanager
Expand All @@ -31,4 +31,4 @@ placement:
- {{ _hosts[0] }}
count: 1
networks:
- {{ cifmw_cephadm_rgw_network }}
- {{ cifmw_cephadm_monitoring_network }}
Loading

0 comments on commit fb1a4c5

Please sign in to comment.