From e93bbd9ed568e98507c792244df58672ab3d84ef Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Tue, 26 Nov 2019 16:24:46 +0000
Subject: [PATCH] Use mariabackup for database backups

Kolla ansible switched its database backup support to mariabackup from
xtrabackup due to incompatibilities. See
https://bugs.launchpad.net/kolla/+bug/1843043 for details.

Change-Id: Ib95771f09fd6d5e71a2af471de47f811e1cab88b
Related-Bug: #1843043
Story: 2006952
Task: 37634
---
 ansible/group_vars/all/kolla                   |  4 +++-
 ansible/kolla-openstack.yml                    |  4 ++--
 .../roles/kolla-openstack/defaults/main.yml    | 18 +++++++++---------
 .../molecule/enable-everything/molecule.yml    |  8 ++++----
 ansible/roles/kolla-openstack/tasks/config.yml |  2 +-
 .../kolla-openstack/templates/backup.my.cnf.j2 |  4 ++--
 ansible/roles/kolla-openstack/vars/main.yml    |  5 -----
 doc/source/administration/overcloud.rst        |  4 ++--
 doc/source/configuration/kolla-ansible.rst     |  2 +-
 etc/kayobe/kolla.yml                           |  1 +
 .../notes/mariabackup-9370d55279c1aa78.yaml    |  9 +++++++++
 11 files changed, 34 insertions(+), 27 deletions(-)
 create mode 100644 releasenotes/notes/mariabackup-9370d55279c1aa78.yaml

diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla
index 2868ecbed..8e2eea9fc 100644
--- a/ansible/group_vars/all/kolla
+++ b/ansible/group_vars/all/kolla
@@ -370,6 +370,9 @@ kolla_enable_keystone: "yes"
 kolla_enable_kibana: "{{ 'yes' if kolla_enable_central_logging | bool or kolla_enable_monasca | bool  else 'no' }}"
 kolla_enable_magnum: "no"
 kolla_enable_manila: "no"
+# TODO(mgoddard): Change this to a plain "no" when support for
+# kolla_enable_xtrabackup has been removed.
+kolla_enable_mariabackup: "{{ kolla_enable_xtrabackup | default('no') }}"
 kolla_enable_mariadb: "yes"
 kolla_enable_monasca: "no"
 kolla_enable_murano: "no"
@@ -385,7 +388,6 @@ kolla_enable_skydive: "no"
 kolla_enable_storm: "{{ 'yes' if kolla_enable_monasca | bool else 'no' }}"
 kolla_enable_swift: "no"
 kolla_enable_telegraf: "no"
-kolla_enable_xtrabackup: "no"
 kolla_enable_zookeeper: "{{ 'yes' if kolla_enable_kafka | bool or kolla_enable_storm | bool else 'no' }}"
 
 ###############################################################################
diff --git a/ansible/kolla-openstack.yml b/ansible/kolla-openstack.yml
index a0e378192..c04c1d97d 100644
--- a/ansible/kolla-openstack.yml
+++ b/ansible/kolla-openstack.yml
@@ -121,6 +121,7 @@
             - { name: keystone, file: keystone.conf }
             - { name: magnum, file: magnum.conf }
             - { name: manila, file: manila.conf }
+            - { name: mariabackup, file: backup.my.cnf }
             - { name: mariadb, file: galera.cnf }
             - { name: murano, file: murano.conf }
             - { name: neutron, file: neutron.conf }
@@ -128,7 +129,6 @@
             - { name: nova, file: nova.conf }
             - { name: octavia, file: octavia.conf }
             - { name: sahara, file: sahara.conf }
-            - { name: xtrabackup, file: backup.my.cnf }
             - { name: zookeeper, file: zookeeper.cfg }
 
         - name: Initialise a fact containing extra configuration
@@ -230,6 +230,7 @@
       kolla_extra_keystone: "{{ kolla_extra_config.keystone | default }}"
       kolla_extra_magnum: "{{ kolla_extra_config.magnum | default }}"
       kolla_extra_manila: "{{ kolla_extra_config.manila | default }}"
+      kolla_extra_mariabackup: "{{ kolla_extra_config.mariabackup | default }}"
       kolla_extra_mariadb: "{{ kolla_extra_config.mariadb | default }}"
       kolla_extra_murano: "{{ kolla_extra_config.murano | default }}"
       kolla_extra_neutron: "{{ kolla_extra_config.neutron | default }}"
@@ -237,6 +238,5 @@
       kolla_extra_nova: "{{ kolla_extra_config.nova | default }}"
       kolla_extra_octavia: "{{ kolla_extra_config.octavia | default }}"
       kolla_extra_sahara: "{{ kolla_extra_config.sahara | default }}"
-      kolla_extra_xtrabackup: "{{ kolla_extra_config.xtrabackup | default }}"
       kolla_extra_zookeeper: "{{ kolla_extra_config.zookeeper | default }}"
       kolla_extra_config_path: "{{ kayobe_config_path }}/kolla/config"
diff --git a/ansible/roles/kolla-openstack/defaults/main.yml b/ansible/roles/kolla-openstack/defaults/main.yml
index a58f863d7..7e14baf76 100644
--- a/ansible/roles/kolla-openstack/defaults/main.yml
+++ b/ansible/roles/kolla-openstack/defaults/main.yml
@@ -337,6 +337,15 @@ kolla_enable_magnum:
 # Free form extra configuration to append to magnum.conf.
 kolla_extra_magnum:
 
+###############################################################################
+# Mariabackup configuration.
+
+# Whether to enable Mariabackup.
+kolla_enable_mariabackup:
+
+# Free form extra configuration to append to backup.my.cnf.
+kolla_extra_mariabackup:
+
 ###############################################################################
 # MariaDB configuration.
 
@@ -455,15 +464,6 @@ kolla_enable_storm:
 # Whether to enable swift.
 kolla_enable_swift:
 
-###############################################################################
-# Xtrabackup configuration.
-
-# Whether to enable Xtrabackup.
-kolla_enable_xtrabackup:
-
-# Free form extra configuration to append to backup.my.cnf.
-kolla_extra_xtrabackup:
-
 ###############################################################################
 # Zookeeper configuration.
 
diff --git a/ansible/roles/kolla-openstack/molecule/enable-everything/molecule.yml b/ansible/roles/kolla-openstack/molecule/enable-everything/molecule.yml
index 176c9e4ca..7d90228b3 100644
--- a/ansible/roles/kolla-openstack/molecule/enable-everything/molecule.yml
+++ b/ansible/roles/kolla-openstack/molecule/enable-everything/molecule.yml
@@ -85,6 +85,10 @@ provisioner:
         kolla_extra_manila: |
           [extra-manila.conf]
           foo=bar
+        kolla_enable_mariabackup: true
+        kolla_extra_mariabackup: |
+          [extra-backup.my.cnf]
+          foo=bar
         kolla_enable_mariadb: true
         kolla_extra_mariadb: |
           [extra-galera.cnf]
@@ -116,10 +120,6 @@ provisioner:
           foo=bar
         kolla_enable_swift: true
         kolla_enable_storm: true
-        kolla_enable_xtrabackup: true
-        kolla_extra_xtrabackup: |
-          [extra-backup.my.cnf]
-          foo=bar
         kolla_enable_zookeeper: true
         kolla_extra_zookeeper: |
           [extra-zookeeper.cfg]
diff --git a/ansible/roles/kolla-openstack/tasks/config.yml b/ansible/roles/kolla-openstack/tasks/config.yml
index 3bc9a2d46..bf931b7b8 100644
--- a/ansible/roles/kolla-openstack/tasks/config.yml
+++ b/ansible/roles/kolla-openstack/tasks/config.yml
@@ -31,13 +31,13 @@
     - { src: keystone.conf.j2, dest: keystone.conf, enabled: "{{ kolla_enable_keystone }}" }
     - { src: magnum.conf.j2, dest: magnum.conf, enabled: "{{ kolla_enable_magnum }}" }
     - { src: manila.conf.j2, dest: manila.conf, enabled: "{{ kolla_enable_manila }}" }
+    - { src: backup.my.cnf.j2, dest: backup.my.cnf, enabled: "{{ kolla_enable_mariabackup }}" }
     - { src: ml2_conf.ini.j2, dest: neutron/ml2_conf.ini, enabled: "{{ kolla_enable_neutron }}" }
     - { src: murano.conf.j2, dest: murano.conf, enabled: "{{ kolla_enable_murano }}" }
     - { src: neutron.conf.j2, dest: neutron.conf, enabled: "{{ kolla_enable_neutron }}" }
     - { src: nova.conf.j2, dest: nova.conf, enabled: "{{ kolla_enable_nova }}" }
     - { src: octavia.conf.j2, dest: octavia.conf, enabled: "{{ kolla_enable_octavia }}" }
     - { src: sahara.conf.j2, dest: sahara.conf, enabled: "{{ kolla_enable_sahara }}" }
-    - { src: backup.my.cnf.j2, dest: backup.my.cnf, enabled: "{{ kolla_enable_xtrabackup }}" }
     - { src: zookeeper.cfg.j2, dest: zookeeper.cfg, enabled: "{{ kolla_enable_zookeeper }}" }
   when: item.enabled | bool
 
diff --git a/ansible/roles/kolla-openstack/templates/backup.my.cnf.j2 b/ansible/roles/kolla-openstack/templates/backup.my.cnf.j2
index bb29de1f3..7213d824d 100644
--- a/ansible/roles/kolla-openstack/templates/backup.my.cnf.j2
+++ b/ansible/roles/kolla-openstack/templates/backup.my.cnf.j2
@@ -1,9 +1,9 @@
 # {{ ansible_managed }}
 
-{% if kolla_extra_xtrabackup %}
+{% if kolla_extra_mariabackup %}
 #######################
 # Extra configuration
 #######################
 
-{{ kolla_extra_xtrabackup }}
+{{ kolla_extra_mariabackup }}
 {% endif %}
diff --git a/ansible/roles/kolla-openstack/vars/main.yml b/ansible/roles/kolla-openstack/vars/main.yml
index f62be2c16..01549a092 100644
--- a/ansible/roles/kolla-openstack/vars/main.yml
+++ b/ansible/roles/kolla-openstack/vars/main.yml
@@ -198,11 +198,6 @@ kolla_openstack_custom_config:
       - container.ring.gz
       - object.builder
       - object.ring.gz
-  # Xtrabackup.
-  - src: "{{ kolla_extra_config_path }}/xtrabackup"
-    dest: "{{ kolla_node_custom_config_path }}/xtrabackup"
-    patterns: "*"
-    enabled: "{{ kolla_enable_xtrabackup }}"
   # Zookeeper.
   - src: "{{ kolla_extra_config_path }}/zookeeper"
     dest: "{{ kolla_node_custom_config_path }}/zookeeper"
diff --git a/doc/source/administration/overcloud.rst b/doc/source/administration/overcloud.rst
index 87206b55a..46d620910 100644
--- a/doc/source/administration/overcloud.rst
+++ b/doc/source/administration/overcloud.rst
@@ -190,12 +190,12 @@ Performing Database Backups
 Database backups can be performed using the underlying support in Kolla
 Ansible.
 
-In order to enable backups, enable Xtrabackup in
+In order to enable backups, enable Mariabackup in
 ``${KAYOBE_CONFIG_PATH}/kolla.yml``:
 
 .. code-block:: console
 
-   kolla_enable_xtrabackup: true
+   kolla_enable_mariabackup: true
 
 To apply this change, use the :ref:`kayobe overcloud service reconfigure
 <overcloud-administration-reconfigure>` command.
diff --git a/doc/source/configuration/kolla-ansible.rst b/doc/source/configuration/kolla-ansible.rst
index 0a0f93a6a..691e0a175 100644
--- a/doc/source/configuration/kolla-ansible.rst
+++ b/doc/source/configuration/kolla-ansible.rst
@@ -362,7 +362,7 @@ which files are supported.
    =============================== =======================================================
    File                            Purpose
    =============================== =======================================================
-   ``backup.my.cnf``               Xtrabackup configuration.
+   ``backup.my.cnf``               Mariabackup configuration.
    ``barbican/*``                  Extended Barbican configuration.
    ``blazar.conf``                 Blazar configuration.
    ``blazar/*``                    Extended Blazar configuration.
diff --git a/etc/kayobe/kolla.yml b/etc/kayobe/kolla.yml
index 591bb5fbb..a2cb8116a 100644
--- a/etc/kayobe/kolla.yml
+++ b/etc/kayobe/kolla.yml
@@ -217,6 +217,7 @@
 #kolla_enable_manila_backend_hnas:
 #kolla_enable_manila_backend_cephfs_native:
 #kolla_enable_manila_backend_cephfs_nfs:
+#kolla_enable_mariabackup:
 #kolla_enable_mistral:
 #kolla_enable_monasca:
 #kolla_enable_mongodb:
diff --git a/releasenotes/notes/mariabackup-9370d55279c1aa78.yaml b/releasenotes/notes/mariabackup-9370d55279c1aa78.yaml
new file mode 100644
index 000000000..545315074
--- /dev/null
+++ b/releasenotes/notes/mariabackup-9370d55279c1aa78.yaml
@@ -0,0 +1,9 @@
+---
+upgrade:
+  - |
+    The database backup support in Kolla Ansible has been modified to use
+    Mariabackup rather than Xtrabackup.
+deprecations:
+  - |
+    The ``kolla_enable_xtrabackup`` variable is deprecated in favour of
+    ``kolla_enable_mariabackup``.