From c4a6944c7bc09faf0eca24044b2776014a9e92cb Mon Sep 17 00:00:00 2001 From: Juan Larriba Date: Fri, 7 May 2021 12:02:30 +0200 Subject: [PATCH] Move the snapshots feature to optional/beta Previously a commit[1] introduced a new way of doing backup, using "snapshots", that do not require to bring down the whole controller to take the backup. On that commit, the old way was removed, which do not follow the deprecation procedure. This commits reintroduces the old way of performing backups via stopping the controllers and move the snapshots feature to an optional, user-selected feature. This was not a clean cherry-pick due to different role names (backup_and_restore vs backup-and-restore) so manual merge has been done. [1] https://review.opendev.org/c/openstack/tripleo-ansible/+/786380 (cherry picked from commit 00a17ffb4a2262bffe750330bee333a8d3948247) Change-Id: I49944d585825b32052278cd865a74c46dcb5eaa4 (cherry picked from commit 2b56b7f933adda7bd26c8ccf12bee179beb1dffb) (cherry picked from commit 091dd3fbb9385c65552db8f44e779544d617a18d) --- .../backup/tasks/db_backup.yml | 6 +++- .../backup-and-restore/backup/tasks/main.yml | 8 +++++ .../backup/tasks/pacemaker_unstandby.yml | 32 +++++++++++++++++++ .../backup-and-restore/defaults/main.yml | 4 +++ .../molecule/default/playbook.yml | 1 - .../roles/backup-and-restore/tasks/main.yml | 10 +++++- 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tripleo_ansible/roles/backup-and-restore/backup/tasks/pacemaker_unstandby.yml diff --git a/tripleo_ansible/roles/backup-and-restore/backup/tasks/db_backup.yml b/tripleo_ansible/roles/backup-and-restore/backup/tasks/db_backup.yml index 03fe21cdd..d043b064f 100644 --- a/tripleo_ansible/roles/backup-and-restore/backup/tasks/db_backup.yml +++ b/tripleo_ansible/roles/backup-and-restore/backup/tasks/db_backup.yml @@ -53,6 +53,7 @@ when: - enabled_galera - tripleo_backup_and_restore_service_manager|bool + - not tripleo_backup_and_restore_enable_snapshots|bool run_once: true tags: - bar_create_recover_image @@ -60,7 +61,7 @@ - name: Wait until pacemaker has Galera up&running shell: | set -o pipefail - netstat -tunlp | grep ":3306 " | sed -e 's/.*\///' + ss -tunlp | grep ":3306 " | sed -e 's/.*\///' register: mysql_result retries: 300 until: mysql_result is search('mysqld') @@ -68,6 +69,7 @@ when: - enabled_galera - tripleo_backup_and_restore_service_manager|bool + - not tripleo_backup_and_restore_enable_snapshots|bool tags: - bar_create_recover_image @@ -132,6 +134,7 @@ - tripleo_backup_and_restore_mysql_container == "mysql" - not enabled_galera - tripleo_backup_and_restore_service_manager|bool + - not tripleo_backup_and_restore_enable_snapshots|bool tags: - bar_create_recover_image @@ -140,6 +143,7 @@ when: - enabled_galera - tripleo_backup_and_restore_service_manager|bool + - not tripleo_backup_and_restore_enable_snapshots|bool run_once: true tags: - bar_create_recover_image diff --git a/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml index 5952dfb85..f5126fb6d 100644 --- a/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml +++ b/tripleo_ansible/roles/backup-and-restore/backup/tasks/main.yml @@ -32,6 +32,14 @@ tags: - always +- name: Take this node out of pacemaker + command: pcs node standby + when: + - pacemaker_enabled + - tripleo_backup_and_restore_enable_snapshots|bool + tags: + - bar_create_recover_image + - name: Create the node backup become: true command: rear {{ '-s ' if tripleo_backup_and_restore_rear_simulate else '' }}-d -v mkbackup diff --git a/tripleo_ansible/roles/backup-and-restore/backup/tasks/pacemaker_unstandby.yml b/tripleo_ansible/roles/backup-and-restore/backup/tasks/pacemaker_unstandby.yml new file mode 100644 index 000000000..7162de7c8 --- /dev/null +++ b/tripleo_ansible/roles/backup-and-restore/backup/tasks/pacemaker_unstandby.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2019 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. +# +# Start again pacemaker +- name: Add the node to the pacemaker cluster + command: pcs node unstandby + tags: + - bar_create_recover_image + +- name: Wait until pacemaker has Galera up&running + shell: | + set -o pipefail + ss -tunlp | grep ":3306 " | sed -e 's/.*\///' + register: mysql_result + retries: 300 + until: mysql_result is search('mysqld') + delay: 5 + tags: + - bar_create_recover_image diff --git a/tripleo_ansible/roles/backup-and-restore/defaults/main.yml b/tripleo_ansible/roles/backup-and-restore/defaults/main.yml index 7964b4adb..265ead8a2 100644 --- a/tripleo_ansible/roles/backup-and-restore/defaults/main.yml +++ b/tripleo_ansible/roles/backup-and-restore/defaults/main.yml @@ -31,6 +31,10 @@ tripleo_backup_and_restore_mysql_backup_file: "openstack-backup-mysql.sql" # Default name for the Undercloud mysql DB grants file tripleo_backup_and_restore_mysql_grants_file: "openstack-backup-mysql-grants.sql" +# If this is false, backup of the overcloud is taken by stopping it completely. Enable it to do a +# backup stopping only one node at a time, maintaining the controller active during the backup duration. +tripleo_backup_and_restore_enable_snapshots: true + # All variables within this role should have a prefix of "tripleo_backup_and_restore" tripleo_backup_and_restore_debug: false # By default this should be the Undercloud node diff --git a/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml b/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml index dadb88044..51edaa8a1 100644 --- a/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml +++ b/tripleo_ansible/roles/backup-and-restore/molecule/default/playbook.yml @@ -23,5 +23,4 @@ tripleo_backup_and_restore_nfs_server: localhost tripleo_container_cli: podman tripleo_backup_and_restore_rear_simulate: true - tripleo_backup_and_restore_service_manager: false tripleo_backup_and_restore_hiera_config_file: "{{ ansible_user_dir }}/hiera.yaml" diff --git a/tripleo_ansible/roles/backup-and-restore/tasks/main.yml b/tripleo_ansible/roles/backup-and-restore/tasks/main.yml index 837be0a86..cf2404d25 100644 --- a/tripleo_ansible/roles/backup-and-restore/tasks/main.yml +++ b/tripleo_ansible/roles/backup-and-restore/tasks/main.yml @@ -42,6 +42,7 @@ import_tasks: ../backup/tasks/service_manager_pause.yml when: - tripleo_backup_and_restore_service_manager + - not tripleo_backup_and_restore_enable_snapshots|bool - name: Backup the database import_tasks: ../backup/tasks/db_backup.yml @@ -57,4 +58,11 @@ - name: Service management import_tasks: ../backup/tasks/service_manager_unpause.yml when: - - tripleo_backup_and_restore_service_manager + - tripleo_backup_and_restore_service_manager|bool + - not tripleo_backup_and_restore_enable_snapshots|bool + + - name: Pacemaker management + import_tasks: ../backup/tasks/pacemaker_unstandby.yml + when: + - pacemaker_enabled + - tripleo_backup_and_restore_enable_snapshots|bool