Skip to content

Commit d93ea23

Browse files
committed
[multiple] Accept CA certificate if expired when CRC is used
It can happen that the image used by the CRC has expired certificate, so it require to approve new generated certificate before making test. The CRC log shows a log message: level=info msg="Kubelet serving certificate has expired, waiting for automatic renewal... [will take up to 5 minutes]" Failed to renew TLS certificates: please check if a newer CRC release is available: Temporary error: certificate /var/lib/kubelet/pki/kubelet-server-current.pem still expired (x59) Wait for the cluster to be stable when CA cert is expired. Also move all crc command to single playbook, for easier maintenance. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent db364fb commit d93ea23

22 files changed

Lines changed: 133 additions & 104 deletions

File tree

roles/cert_manager/molecule/default/prepare.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
roles:
2121
- role: test_deps
2222
tasks:
23-
- name: Ensure CRC is started
24-
ansible.builtin.command:
25-
cmd: crc start
23+
- name: Start CRC
24+
ansible.builtin.include_role:
25+
name: cifmw_helpers
26+
tasks_from: crc_start.yml

roles/ci_local_storage/molecule/default/prepare.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
roles:
2121
- role: test_deps
2222
tasks:
23-
- name: Ensure CRC is started
24-
ansible.builtin.command:
25-
cmd: crc start
23+
- name: Start CRC
24+
ansible.builtin.include_role:
25+
name: cifmw_helpers
26+
tasks_from: crc_start.yml
2627

2728
- name: Inject crc hostname/IP in hosts
2829
become: true

roles/cifmw_helpers/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
That role was created to replace nested Ansible (Ansible that execute
44
ansible or ansible-playbook binary using command/shell module) execution in
55
this project.
6+
Role might contain tasks, required for test jobs, like molecule job.
67

78
## Helper for Zuul executor cifmw general collection
89

@@ -389,3 +390,30 @@ it parse all yaml files available in the directory.
389390
msg: |
390391
{{ noop_helper_var }}
391392
```
393+
394+
## Test project helpers
395+
396+
### Start CRC
397+
398+
In some CI jobs, we are using [crc](https://crc.dev/) to verify the role functionality.
399+
Example usage:
400+
401+
* Setup crc with default resources
402+
403+
```yaml
404+
- name: Start CRC
405+
ansible.builtin.include_role:
406+
name: cifmw_helpers
407+
tasks_from: crc_start.yml
408+
```
409+
410+
* Setup crc with limited resources, like memory, disk, cpu - [more](https://crc.dev/docs/installing/)
411+
412+
```yaml
413+
- name: Start CRC
414+
vars:
415+
cifmw_helpers_crc_additional_params: "--memory 14000 --disk-size 80 --cpus 6"
416+
ansible.builtin.include_role:
417+
name: cifmw_helpers
418+
tasks_from: crc_start.yml
419+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Ensure CRC is started
3+
ansible.builtin.command:
4+
cmd: >
5+
crc start {{ cifmw_helpers_crc_additional_params | default('') }}
6+
register: _crc_output
7+
ignore_errors: true # noqa: ignore-errors
8+
9+
- name: Login to the OpenShift when certificate is expired
10+
when: "'Kubelet serving certificate has expired' in _crc_output.stderr"
11+
ansible.builtin.command: >
12+
oc login
13+
-u kubeadmin
14+
https://api.crc.testing:6443
15+
--insecure-skip-tls-verify
16+
register: _openshift_login
17+
until: _openshift_login.rc == 0
18+
retries: 90
19+
delay: 10
20+
changed_when: false

roles/env_op_images/molecule/default/prepare.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
- role: ci_setup
2525
- role: install_yamls
2626
tasks:
27-
- name: Ensure CRC is started
28-
ansible.builtin.command:
29-
cmd: crc start --memory 14000 --disk-size 80 --cpus 6
27+
- name: Start CRC
28+
vars:
29+
cifmw_helpers_crc_additional_params: "--memory 14000 --disk-size 80 --cpus 6"
30+
ansible.builtin.include_role:
31+
name: cifmw_helpers
32+
tasks_from: crc_start.yml

roles/install_openstack_ca/molecule/default/prepare.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,16 @@
2121
cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}"
2222
cifmw_openshift_kubeconfig: "{{ ansible_user_dir }}/.crc/machines/crc/kubeconfig"
2323
pre_tasks:
24-
- name: Ensure CRC is started
25-
async: 1800
26-
poll: 0
27-
register: _crc_start
28-
ansible.builtin.command:
29-
cmd: crc start
24+
- name: Start CRC
25+
ansible.builtin.include_role:
26+
name: cifmw_helpers
27+
tasks_from: crc_start.yml
3028
roles:
3129
- role: test_deps
3230
- role: ci_setup
3331
- role: install_yamls
3432
- role: ci_local_storage
3533
tasks:
36-
- name: Check for CRC status
37-
ansible.builtin.async_status:
38-
jid: "{{ _crc_start.ansible_job_id }}"
39-
register: _crc_status
40-
until: _crc_status.finished
41-
retries: 100
42-
delay: 10
43-
4434
- name: Install install_yamls dependencies
4535
ansible.builtin.include_role:
4636
name: 'install_yamls_makes'

roles/manage_secrets/molecule/dataplane_ssh/prepare.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717
- name: Prepare
1818
hosts: all
1919
pre_tasks:
20-
- name: Ensure CRC is started
21-
async: 1800
22-
poll: 0
23-
register: _crc_start
24-
ansible.builtin.command:
25-
cmd: crc start
20+
- name: Start CRC
21+
ansible.builtin.include_role:
22+
name: cifmw_helpers
23+
tasks_from: crc_start.yml
2624
roles:
2725
- role: test_deps
2826
- role: ci_setup
2927
- role: install_yamls
30-
tasks:
31-
- name: Check for CRC status
32-
ansible.builtin.async_status:
33-
jid: "{{ _crc_start.ansible_job_id }}"
34-
register: _crc_status
35-
until: _crc_status.finished
36-
retries: 100
37-
delay: 10

roles/manage_secrets/molecule/nova_migration/prepare.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717
- name: Prepare
1818
hosts: all
1919
pre_tasks:
20-
- name: Ensure CRC is started
21-
async: 1800
22-
poll: 0
23-
register: _crc_start
24-
ansible.builtin.command:
25-
cmd: crc start
20+
- name: Start CRC
21+
ansible.builtin.include_role:
22+
name: cifmw_helpers
23+
tasks_from: crc_start.yml
2624
roles:
2725
- role: test_deps
2826
- role: ci_setup
2927
- role: install_yamls
30-
tasks:
31-
- name: Check for CRC status
32-
ansible.builtin.async_status:
33-
jid: "{{ _crc_start.ansible_job_id }}"
34-
register: _crc_status
35-
until: _crc_status.finished
36-
retries: 100
37-
delay: 10

roles/manage_secrets/molecule/osp_secrets/prepare.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717
- name: Prepare
1818
hosts: all
1919
pre_tasks:
20-
- name: Ensure CRC is started
21-
async: 1800
22-
poll: 0
23-
register: _crc_start
24-
ansible.builtin.command:
25-
cmd: crc start
20+
- name: Start CRC
21+
ansible.builtin.include_role:
22+
name: cifmw_helpers
23+
tasks_from: crc_start.yml
2624
roles:
2725
- role: test_deps
2826
- role: ci_setup
2927
- role: install_yamls
30-
tasks:
31-
- name: Check for CRC status
32-
ansible.builtin.async_status:
33-
jid: "{{ _crc_start.ansible_job_id }}"
34-
register: _crc_status
35-
until: _crc_status.finished
36-
retries: 100
37-
delay: 10

roles/openshift_login/molecule/default/prepare.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- role: install_yamls
2424

2525
tasks:
26-
- name: Ensure CRC is started
27-
ansible.builtin.command:
28-
cmd: crc start
26+
- name: Start CRC
27+
ansible.builtin.include_role:
28+
name: cifmw_helpers
29+
tasks_from: crc_start.yml

0 commit comments

Comments
 (0)