Allow combining system_upgrade_prepare and system_upgrade_run into system_upgrade

Previously we required the operator to run two separate commands for
the "prepare" and "run" phases of operating system upgrade. This
commit refactors the upgrade_tasks with these tags so that running the
whole system upgrade is possible via a single command with `--tags
system_upgrade`.

Allowing to run in a single command requires being more careful about
what can happen in which step number in the upgrade tasks. The upgrade
steps for system upgrade are now explicitly documented in composable
services readme.

The existing system_upgrade_run and system_upgrade_prepare tasks were
checked and moved into the appropriate steps. In the case of
pacemaker, it required moving the cluster stop/destroy action into a
single file with removing all containers, to guarantee that the
cluster is stopped before the container removal, otherwise pacemaker
would try to spawn new containers.

Change-Id: I3cd78de8d07be46ee01006dd7e039c285991d14a
Partial-Bug: #1831690
This commit is contained in:
Jiri Stransky 2019-08-13 15:01:44 +02:00
parent d4db2fa532
commit 206625d4f5
5 changed files with 64 additions and 28 deletions

View File

@ -291,6 +291,24 @@ Note that the services are not started in the upgrade tasks - we instead re-run
puppet which does any reconfiguration required for the new version, then starts puppet which does any reconfiguration required for the new version, then starts
the services. the services.
When running an OS upgrade via the tags `system_upgrade_prepare` and
`system_upgrade_run`, or the combined tag `system_upgrade`, the steps
corellate to the following:
1) Any pre-service-stop actions. (`system_upgrade_prepare`)
2) Stop all services. (`system_upgrade_prepare`)
3) Post-service-stop actions like removing packages before the
upgrade. (`system_upgrade_prepare`)
4) Step reserved for the `tripleo-packages` service. Only package
download for upgrade (under `system_upgrade_prepare` tag), and
reboot for performing the offline upgrade (under
`system_upgrade_run` tag) happens here.
5) Any post-upgrade tasks (`system_upgrade_run`).
Nova Server Metadata Settings Nova Server Metadata Settings
----------------------------- -----------------------------

View File

@ -393,14 +393,13 @@ outputs:
- vars: - vars:
mysql_upgrade_persist: {get_param: MysqlUpgradePersist} mysql_upgrade_persist: {get_param: MysqlUpgradePersist}
when: when:
- step|int == 1 - step|int == 3
- mysql_upgrade_persist - mysql_upgrade_persist
tags: tags:
- never - never
- system_upgrade
- system_upgrade_prepare - system_upgrade_prepare
block: block:
- name: Ban galera from local node
command: /usr/sbin/pcs resource ban galera-bundle {{ansible_hostname}} --wait
- name: Persist mysql data - name: Persist mysql data
include_role: include_role:
name: tripleo-persist name: tripleo-persist
@ -410,10 +409,11 @@ outputs:
- vars: - vars:
mysql_upgrade_persist: {get_param: MysqlUpgradePersist} mysql_upgrade_persist: {get_param: MysqlUpgradePersist}
when: when:
- step|int == 1 - step|int == 5
- mysql_upgrade_persist - mysql_upgrade_persist
tags: tags:
- never - never
- system_upgrade
- system_upgrade_run - system_upgrade_run
block: block:
- name: Restore mysql data - name: Restore mysql data

View File

@ -161,22 +161,6 @@ outputs:
step_config: | step_config: |
include ::tripleo::profile::base::pacemaker include ::tripleo::profile::base::pacemaker
upgrade_tasks: upgrade_tasks:
- name: system_upgrade_prepare step 2
tags:
- never
- system_upgrade_prepare
when: step|int == 2
block:
- name: Check if pcs is present
stat:
path: /usr/sbin/pcs
register: pcs_stat
- name: Stop pacemaker cluster
pacemaker_cluster: state=offline
when: pcs_stat.stat.exists
- name: destroy pacemaker cluster
command: /usr/sbin/pcs cluster destroy
when: pcs_stat.stat.exists
- name: upgrade step 0 - name: upgrade step 0
when: step|int == 0 when: step|int == 0
vars: vars:

View File

@ -127,15 +127,32 @@ outputs:
service_config_settings: {} service_config_settings: {}
upgrade_tasks: upgrade_tasks:
- name: Stop all services by stopping all docker containers - name: system_upgrade_prepare step 2
when:
- (step | int) == 3
include_role:
name: tripleo-podman
tasks_from: tripleo_docker_stop.yml
tags: tags:
- never - never
- system_upgrade
- system_upgrade_prepare - system_upgrade_prepare
when:
- (step | int) == 2
block:
- name: Check if pcs is present
stat:
path: /usr/sbin/pcs
register: pcs_stat
- name: Stop pacemaker cluster before stopping all docker containers
pacemaker_cluster: state=offline
when: pcs_stat.stat.exists
- name: Destroy pacemaker cluster
command: /usr/sbin/pcs cluster destroy
when: pcs_stat.stat.exists
- name: Stop all services by stopping all docker containers
include_role:
name: tripleo-podman
tasks_from: tripleo_docker_stop.yml
tags:
- never
- system_upgrade
- system_upgrade_prepare
- name: Run podman install - name: Run podman install
when: when:

View File

@ -99,9 +99,11 @@ outputs:
upgrade_leapp_debug: {get_param: UpgradeLeappDebug} upgrade_leapp_debug: {get_param: UpgradeLeappDebug}
upgrade_leapp_devel_skip_rhsm: {get_param: UpgradeLeappDevelSkipRhsm} upgrade_leapp_devel_skip_rhsm: {get_param: UpgradeLeappDevelSkipRhsm}
upgrade_leapp_reboot_timeout: {get_param: UpgradeLeappRebootTimeout} upgrade_leapp_reboot_timeout: {get_param: UpgradeLeappRebootTimeout}
- name: system_upgrade_prepare step 3 - name: system_upgrade_prepare step 3
tags: tags:
- never - never
- system_upgrade
- system_upgrade_prepare - system_upgrade_prepare
when: step|int == 3 when: step|int == 3
block: block:
@ -121,22 +123,37 @@ outputs:
name: leapp name: leapp
state: latest state: latest
when: upgrade_leapp_enabled when: upgrade_leapp_enabled
- name: system_upgrade_prepare step 4
tags:
- never
- system_upgrade
- system_upgrade_prepare
when: step|int == 4
block:
- name: run leapp upgrade (download packages) - name: run leapp upgrade (download packages)
shell: > shell: >
{% if upgrade_leapp_devel_skip_rhsm|default(false) %}LEAPP_DEVEL_SKIP_RHSM=1{% endif %} {% if upgrade_leapp_devel_skip_rhsm|default(false) %}LEAPP_DEVEL_SKIP_RHSM=1{% endif %}
leapp upgrade leapp upgrade
{% if upgrade_leapp_debug|default(true) %}--debug{% endif %} {% if upgrade_leapp_debug|default(true) %}--debug{% endif %}
when: upgrade_leapp_enabled when: upgrade_leapp_enabled
- name: system_upgrade_run step 5
- name: system_upgrade_run step 4
tags: tags:
- never - never
- system_upgrade
- system_upgrade_run - system_upgrade_run
when: step|int == 5 # In case someone needs to re-run system_upgrade_run post-tasks
# but doesn't want to reboot, they can run with
# `--skip-tags system_upgrade_reboot`.
- system_upgrade_reboot
when: step|int == 4
block: block:
- name: reboot to perform the upgrade - name: reboot to perform the upgrade
reboot: reboot:
reboot_timeout: "{{upgrade_leapp_reboot_timeout}}" reboot_timeout: "{{upgrade_leapp_reboot_timeout}}"
when: upgrade_leapp_enabled when: upgrade_leapp_enabled
- name: Package and repo update tasks - name: Package and repo update tasks
when: step|int == 0 when: step|int == 0
block: block: