Skip to content

Commit a1c5dbe

Browse files
committed
feat: add dynamic in-place hypervisor upgrade
1 parent ecfbe44 commit a1c5dbe

File tree

4 files changed

+99
-6
lines changed

4 files changed

+99
-6
lines changed

roles/gitlab/defaults/main.yml

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ gitlab_tempest_test_suites: |
1919
2020
gitlab_openstack_release: "2024.1"
2121

22-
gitlab_stages: "{{ gitlab_default_stages | combine(gitlab_extra_stages) | combine(gitlab_runbooks) }}"
22+
gitlab_stages: "{{ gitlab_default_stages | combine(gitlab_extra_stages) | combine(gitlab_runbooks) | combine(gitlab_upstream_stages) }}"
2323

2424
gitlab_default_stages:
2525
build:
@@ -44,10 +44,24 @@ gitlab_runbooks: "{{ gitlab_default_runbooks | combine(gitlab_extra_runbooks) }}
4444
gitlab_default_runbooks:
4545
runbook-overcloud-service-upgrade:
4646
"{{ gitlab_runbook_overcloud_service_upgrade }}"
47+
48+
gitlab_extra_runbooks: {}
49+
50+
gitlab_upstream_stages: "{{ gitlab_default_upstream_stages | combine(gitlab_extra_upstream_stages) }}"
51+
52+
gitlab_default_upstream_stages:
53+
upstream-runbook-in-place-hypervisor-host-upgrade:
54+
"{{ gitlab_upstream_runbook_in_place_hypervisor_host_upgrade }}"
55+
56+
gitlab_extra_upstream_stages: {}
57+
58+
gitlab_downstream_stages: "{{ gitlab_default_downstream_stages | combine(gitlab_extra_downstream_stages) }}"
59+
60+
gitlab_default_downstream_stages:
4761
runbook-in-place-hypervisor-host-upgrade:
4862
"{{ gitlab_runbook_in_place_hypervisor_host_upgrade }}"
4963

50-
gitlab_extra_runbooks: {}
64+
gitlab_extra_downstream_stages: {}
5165

5266
gitlab_stage_build: "{{ gitlab_stage_build_default | combine(gitlab_stage_build_extra) }}"
5367

@@ -590,7 +604,6 @@ gitlab_runbook_in_place_hypervisor_host_upgrade_disable_compute_services: |
590604
- !reference [.kayobe_public_openrc, script]
591605
- !reference [.get_secrets, script]
592606
- .automation/pipeline/playbook-run.sh etc/kayobe/ansible/nova-compute-disable.yml
593-
allow_failure: true
594607
595608
gitlab_runbook_in_place_hypervisor_host_upgrade_drain_hypervisor: |
596609
rules:
@@ -602,7 +615,6 @@ gitlab_runbook_in_place_hypervisor_host_upgrade_drain_hypervisor: |
602615
- !reference [.kayobe_public_openrc, script]
603616
- !reference [.get_secrets, script]
604617
- .automation/pipeline/playbook-run.sh etc/kayobe/ansible/nova-compute-disable.yml
605-
allow_failure: true
606618
607619
gitlab_runbook_in_place_hypervisor_host_upgrade_package_update: |
608620
rules:
@@ -623,7 +635,6 @@ gitlab_runbook_in_place_hypervisor_reboot_hypervisor: |
623635
- !reference [.kayobe_public_openrc, script]
624636
- !reference [.get_secrets, script]
625637
- .automation/pipeline/playbook-run.sh etc/kayobe/ansible/reboot.yml
626-
allow_failure: true
627638
628639
gitlab_runbook_in_place_hypervisor_host_upgrade_enable_hypervisor: |
629640
rules:
@@ -635,4 +646,33 @@ gitlab_runbook_in_place_hypervisor_host_upgrade_enable_hypervisor: |
635646
- !reference [.kayobe_public_openrc, script]
636647
- !reference [.get_secrets, script]
637648
- .automation/pipeline/playbook-run.sh etc/kayobe/ansible/nova-compute-disable.yml
638-
allow_failure: true
649+
650+
gitlab_upstream_runbook_in_place_hypervisor_host_upgrade:
651+
a_constructor: "{{ gitlab_upstream_runbook_in_place_hypervisor_host_upgrade_constructor }}"
652+
b_executor: "{{ gitlab_upstream_runbook_in_place_hypervisor_host_upgrade_executor }}"
653+
654+
gitlab_upstream_runbook_in_place_hypervisor_host_upgrade_constructor: |
655+
rules:
656+
- !reference [.active_stage_web_rule, rules]
657+
stage: upstream-runbook-in-place-hypervisor-host-upgrade
658+
script:
659+
- !reference [.kayobe_public_openrc, script]
660+
- !reference [.get_secrets, script]
661+
- .automation/pipeline/playbook-run.sh etc/kayobe/ansible/write-gitlab-pipeline.yml \
662+
-t runbook_in_place_hypervisor_host_upgrade_trigger \
663+
-e kayobe_automation_upgrade_group_name=$KAYOBE_AUTOMATION_UPGRADE_GROUP_NAME \
664+
-e kayobe_automation_upgrade_batch_size=$KAYOBE_AUTOMATION_UPGRADE_BATCH_SIZE
665+
artifacts:
666+
name: runbook-in-place-hypervisor-host-upgrade-trigger.yml
667+
expire_in: 1 hrs
668+
when: always
669+
paths:
670+
- .gitlab/runbook-in-place-hypervisor-host-upgrade-trigger.yml
671+
672+
gitlab_upstream_runbook_in_place_hypervisor_host_upgrade_executor: |
673+
stage: upstream-runbook-in-place-hypervisor-host-upgrade
674+
needs: [a_constructor]
675+
trigger:
676+
include:
677+
- artifact: runbook-in-place-hypervisor-host-upgrade-trigger.yml
678+
job: gitlab_runbook_in_place_hypervisor_host_upgrade_constructor

roles/gitlab/tasks/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
loop:
88
- "{{ gitlab_output_directory }}"
99
- "{{ gitlab_output_directory }}/.gitlab"
10+
tags: always
1011

1112
- name: Ensure gitlab-ci.yml entry point exists
1213
ansible.builtin.template:
@@ -20,6 +21,15 @@
2021
dest: "{{ gitlab_output_directory }}/.gitlab/prelude.yml"
2122
mode: "0644"
2223

24+
- name: Ensure runbook-in-place-hypervisor-host-upgrade-trigger exists
25+
ansible.builtin.template:
26+
src: "runbook-in-place-hypervisor-host-upgrade-trigger.yml.j2"
27+
dest: "{{ gitlab_output_directory }}/.gitlab/runbook-in-place-hypervisor-host-upgrade-trigger.yml"
28+
mode: "0644"
29+
tags:
30+
- never
31+
- runbook-in-place-hypervisor-host-upgrade-trigger
32+
2333
- name: Ensure pipeline stage files exist
2434
ansible.builtin.template:
2535
src: "stage.yml.j2"
@@ -30,3 +40,14 @@
3040
loop: "{{ gitlab_stages.keys() }}"
3141
loop_control:
3242
loop_var: stage
43+
44+
- name: Ensure downstream pipelines exist
45+
ansible.builtin.template:
46+
src: "downstream.yml.j2"
47+
dest: "{{ gitlab_output_directory }}/.gitlab/{{ stage }}.yml"
48+
mode: "0644"
49+
vars:
50+
current_stage: "{{ stage }}"
51+
loop: "{{ gitlab_downstream_stages.keys() }}"
52+
loop_control:
53+
loop_var: stage
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
include:
3+
- .gitlab/prelude.yml
4+
{%+ for job_name in gitlab_downstream_stages[stage].keys() +%}
5+
{%- if gitlab_downstream_stages[stage][job_name] +%}
6+
{{ job_name }}:
7+
{{ gitlab_downstream_stages[stage][job_name] | indent(2) }}
8+
{%- endif -%}
9+
{%- endfor -%}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
{% set group_name = kayobe_automation_upgrade_group_name | default('compute') %}
3+
{% set groups_to_avoid = ['storage', 'controllers', 'ceph'] %}
4+
{% if kayobe_automation_upgrade_hosts is defined %}
5+
{% set all_nodes = kayobe_automation_upgrade_hosts %}
6+
{% else %}
7+
{%- set all_nodes = groups[group_name] %}
8+
{% endif %}
9+
{% set ns = namespace(nodes_to_upgrade=all_nodes) %}
10+
{% for group in groups_to_avoid %}
11+
{% set ns.nodes_to_upgrade = ns.nodes_to_upgrade | difference(groups[group] | default([])) %}
12+
{% endfor %}
13+
{% set nodes_to_upgrade = ns.nodes_to_upgrade | sort %}
14+
{%- set batch_size = kayobe_automation_upgrade_batch_size | default(3) | int %}
15+
runbook_inplace_upgrade_trigger:
16+
stage: trigger
17+
parallel:
18+
matrix:
19+
{% for i in range(0, nodes_to_upgrade | length, batch_size) %}
20+
- NODES: {{ nodes_to_upgrade[i:i + batch_size] | list }}
21+
{% endfor %}
22+
trigger:
23+
include: ./gitlab/runbook-in-place-hypervisor-host-upgrade.yml

0 commit comments

Comments
 (0)