From 016c0f577c535def40dd32ddf41e6cb145a2f9b8 Mon Sep 17 00:00:00 2001
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
Date: Thu, 12 Sep 2019 11:48:07 +0200
Subject: [PATCH] Drop Percona XtraBackup in favour of MariaDB Backup

XtraBackup started failing to install on Ubuntu and does not support
MariaDB 10.3 version.

Related-Bug: #1843043

Change-Id: I9cf62c8e03a02574d85e5349df1d23a51d4c99be
---
 README.rst                                    |  3 +-
 docker/base/Dockerfile.j2                     |  5 ----
 docker/base/percona-release.repo              | 15 ----------
 docker/base/sources.list.ubuntu               |  4 ---
 docker/mariadb/Dockerfile.j2                  | 19 +++++--------
 docker/{xtrabackup => mariadb}/backup.sh      |  5 ++--
 docker/xtrabackup/Dockerfile.j2               | 28 -------------------
 kolla/image/build.py                          |  2 --
 .../drop-xtrabackup-e58a97b617ff708c.yaml     |  5 ++++
 tests/templates/template_overrides.j2         |  3 --
 tests/vars/zuul.yml                           |  1 -
 11 files changed, 15 insertions(+), 75 deletions(-)
 delete mode 100644 docker/base/percona-release.repo
 rename docker/{xtrabackup => mariadb}/backup.sh (90%)
 mode change 100755 => 100644
 delete mode 100644 docker/xtrabackup/Dockerfile.j2
 create mode 100644 releasenotes/notes/drop-xtrabackup-e58a97b617ff708c.yaml

diff --git a/README.rst b/README.rst
index 12be6d0140..5f29130e63 100644
--- a/README.rst
+++ b/README.rst
@@ -154,8 +154,7 @@ Kolla provides images to deploy the following infrastructure components:
 - `Open vSwitch <http://openvswitch.org/>`__ and Linuxbridge back ends for Neutron.
 - `Linux ptp <http://linuxptp.sourceforge.net/>`__ an implementation of the Precision
   Time Protocol (PTP) according to IEEE standard 1588 for Linux.
-- `Percona XtraBackup <https://www.percona.com/software/mysql-database/percona-xtrabackup/>`__
-  A tool which provides a method of performing a hot backup of your MySQL data while the
+- MariaDB Backup A tool which provides a method of performing a hot backup of your MySQL data while the
   system is running.
 - `Prometheus <https://prometheus.io/>`__ an open-source systems monitoring
   and alerting toolkit originally built at SoundCloud.
diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2
index 1acfe02020..d72427a962 100644
--- a/docker/base/Dockerfile.j2
+++ b/docker/base/Dockerfile.j2
@@ -80,12 +80,10 @@ COPY yum.conf /etc/yum.conf
         'grafana.repo',
         'influxdb.repo',
         'opendaylight.repo',
-        'percona-release.repo',
         'rabbitmq_rabbitmq-server.repo',
         'td.repo'
     ] %}
 
-    ## NOTE(yoctozepto): Percona keys omitted on purpose (handled via the repo file for compatibility with Zuul)
     {% set base_yum_repo_keys = [
         'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
         'https://packages.grafana.com/gpg.key',
@@ -342,7 +340,6 @@ COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
     {# 391A9AA2147192839E9DB0315EDB1B62EC4926EA -- Canonical Cloud Archive Signing Key <ftpmaster@canonical.com> #}
     {# 46095ACC8548582C1A2699A9D27D666CD88E42B4 -- Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org> #}
     {# 49B07274951063870A8B7EAE7B8AA1A344C05248 -- Opendaylight Signing Key <https://launchpad.net/~odl-team> #}
-    {# 4D1BB29D63D98E422B2113B19334A25F8507EFA5 -- Percona MySQL Development Team (Packaging key) <mysql-dev@percona.com> #}
     {# 58118E89F3A912897C070ADBF76221572C52609D -- Docker Release Tool (releasedocker) <docker@docker.com> #}
     {# 4D8EB5FDA37AB55F41A135203BF88A0C6A770882 -- Apache Qpid PPA Signing Key <dev@qpid.apache.org> #}
     {# 901F9177AB97ACBE                         -- Treasure Data, Inc (Treasure Agent Official Signing key) <support@treasure-data.com> #}
@@ -352,7 +349,6 @@ COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
       '391A9AA2147192839E9DB0315EDB1B62EC4926EA',
       '46095ACC8548582C1A2699A9D27D666CD88E42B4',
       '49B07274951063870A8B7EAE7B8AA1A344C05248',
-      '4D1BB29D63D98E422B2113B19334A25F8507EFA5',
       '58118E89F3A912897C070ADBF76221572C52609D',
       '4D8EB5FDA37AB55F41A135203BF88A0C6A770882',
       '901F9177AB97ACBE',
@@ -367,7 +363,6 @@ COPY apt_preferences.{{ base_distro }} /etc/apt/preferences
 {% elif base_distro == 'debian' %}
     {% set base_apt_keys = [
       '46095ACC8548582C1A2699A9D27D666CD88E42B4',
-      '4D1BB29D63D98E422B2113B19334A25F8507EFA5',
     ] %}
     {% set remote_apt_keys = [
       'https://download.docker.com/linux/debian/gpg',
diff --git a/docker/base/percona-release.repo b/docker/base/percona-release.repo
deleted file mode 100644
index 74bb1623a8..0000000000
--- a/docker/base/percona-release.repo
+++ /dev/null
@@ -1,15 +0,0 @@
-[percona-release-$basearch]
-name = Percona-Release YUM repository - $basearch
-baseurl = https://repo.percona.com/release/$releasever/RPMS/$basearch
-enabled = 0
-gpgcheck = 1
-gpgkey = https://repo.percona.com/yum/RPM-GPG-KEY-Percona
-         https://repo.percona.com/yum/PERCONA-PACKAGING-KEY
-
-[percona-release-noarch]
-name = Percona-Release YUM repository - noarch
-baseurl = https://repo.percona.com/release/$releasever/RPMS/noarch
-enabled = 0
-gpgcheck = 1
-gpgkey = https://repo.percona.com/yum/RPM-GPG-KEY-Percona
-         https://repo.percona.com/yum/PERCONA-PACKAGING-KEY
diff --git a/docker/base/sources.list.ubuntu b/docker/base/sources.list.ubuntu
index 3ffe3449b5..4e8e4d1219 100644
--- a/docker/base/sources.list.ubuntu
+++ b/docker/base/sources.list.ubuntu
@@ -36,9 +36,5 @@ deb http://ppa.launchpad.net/odl-team/carbon/ubuntu xenial main
 # rabbitmq repo
 deb https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
 
-# Percona XtraBackup repo
-# NOTE(yoctozepto): enabled only in the xtrabackup image (to spare MariaDB deps and allow Zuul override)
-#deb http://repo.percona.com/apt bionic main
-
 # MariaDB repo
 deb http://downloads.mariadb.com/MariaDB/mariadb-10.3/repo/ubuntu bionic main
diff --git a/docker/mariadb/Dockerfile.j2 b/docker/mariadb/Dockerfile.j2
index 55898dc18e..7fa09a30d4 100644
--- a/docker/mariadb/Dockerfile.j2
+++ b/docker/mariadb/Dockerfile.j2
@@ -23,19 +23,11 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
 
 {% elif base_package_type == 'deb' %}
     {% set mariadb_packages = [
-        'expect'
+        'expect',
+        'mariadb-backup',
+        'mariadb-client',
+        'mariadb-server'
     ] %}
-    {% if base_distro == 'debian' %}
-        {% set mariadb_packages = mariadb_packages + [
-            'mariadb-server'
-        ] %}
-    {% else %}
-        {% set mariadb_packages = mariadb_packages + [
-            'mariadb-server',
-            'mariadb-client',
-            'mariadb-backup',
-        ] %}
-    {% endif %}
 {% endif %}
 
 {{ macros.install_packages(mariadb_packages | customizable("packages")) }}
@@ -53,6 +45,9 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start \
 RUN mkdir -p /var/run/mysqld && chown mysql /var/run/mysqld && chmod 755 /var/run/mysqld
 {% endif %}
 
+COPY backup.sh /usr/local/bin/kolla_mariadb_backup.sh
+RUN chmod 755 /usr/local/bin/kolla_mariadb_backup.sh
+
 {% if use_dumb_init %}
 {% block mariadb_entrypoint %}
 # NOTE(mgoddard): Override the dumb-init arguments to avoid passing
diff --git a/docker/xtrabackup/backup.sh b/docker/mariadb/backup.sh
old mode 100755
new mode 100644
similarity index 90%
rename from docker/xtrabackup/backup.sh
rename to docker/mariadb/backup.sh
index f8dff8bd7b..8c494a5ebf
--- a/docker/xtrabackup/backup.sh
+++ b/docker/mariadb/backup.sh
@@ -5,7 +5,7 @@ set -eu
 # Execute a full backup
 backup_full() {
     echo "Taking a full backup"
-    innobackupex --defaults-file=/etc/mysql/my.cnf \
+    mariabackup --defaults-file=/etc/mysql/my.cnf \
         --no-timestamp \
         --stream=xbstream \
         --compress \
@@ -16,7 +16,7 @@ backup_full() {
 # Execute an incremental backup
 backup_incremental() {
     echo "Taking an incremental backup"
-    innobackupex --defaults-file=/etc/mysql/my.cnf \
+    mariabackup --defaults-file=/etc/mysql/my.cnf \
         --no-timestamp \
         --stream=xbstream \
         --compress \
@@ -46,4 +46,3 @@ else
     echo "You need to specify either full or incremental backup options."
     exit 1
 fi
-
diff --git a/docker/xtrabackup/Dockerfile.j2 b/docker/xtrabackup/Dockerfile.j2
deleted file mode 100644
index 341a0d2f3d..0000000000
--- a/docker/xtrabackup/Dockerfile.j2
+++ /dev/null
@@ -1,28 +0,0 @@
-FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }}
-LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
-
-{% block xtrabackup_header %}{% endblock %}
-
-{% import "macros.j2" as macros with context %}
-
-{% if base_package_type == 'rpm' %}
-RUN yum-config-manager --enable percona-release-\*
-{% endif %}
-
-{% if base_package_type == 'deb' %}
-RUN sed -i -e '/percona/ s|^#deb |deb |' /etc/apt/sources.list
-{% endif %}
-
-{% if base_package_type in ['rpm', 'deb'] %}
-    {% set xtrabackup_packages = ['percona-xtrabackup-24', 'qpress'] %}
-{% endif %}
-
-{{ macros.install_packages(xtrabackup_packages | customizable("packages")) }}
-
-COPY backup.sh /usr/local/bin/kolla_mariadb_backup.sh
-RUN chmod 755 /usr/local/bin/kolla_mariadb_backup.sh
-
-CMD /usr/local/bin/kolla_mariadb_backup.sh
-
-{% block xtrabackup_footer %}{% endblock %}
-{% block footer %}{% endblock %}
diff --git a/kolla/image/build.py b/kolla/image/build.py
index 09734591ab..e1b43b7896 100755
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -89,7 +89,6 @@ UNBUILDABLE_IMAGES = {
         "opendaylight",      # no binary package
         "prometheus-mtail",  # no aarch64 binary
         "telegraf",          # no binary package
-        "xtrabackup",        # no binary package
     },
 
     'source': {
@@ -138,7 +137,6 @@ UNBUILDABLE_IMAGES = {
         "qdrouterd",
         "sensu-base",
         "telegraf",      # no binary package
-        "xtrabackup",    # no binary package
     },
     'ubuntu': {
         "cyborg-base",
diff --git a/releasenotes/notes/drop-xtrabackup-e58a97b617ff708c.yaml b/releasenotes/notes/drop-xtrabackup-e58a97b617ff708c.yaml
new file mode 100644
index 0000000000..987bd4df79
--- /dev/null
+++ b/releasenotes/notes/drop-xtrabackup-e58a97b617ff708c.yaml
@@ -0,0 +1,5 @@
+---
+upgrade:
+  - |
+    Percona XtraBackup tool got dropped in favour of MariaDB Backup.
+    "xtrabackup" image is no longer present.
diff --git a/tests/templates/template_overrides.j2 b/tests/templates/template_overrides.j2
index 22baa2a569..adc0194a93 100644
--- a/tests/templates/template_overrides.j2
+++ b/tests/templates/template_overrides.j2
@@ -33,7 +33,6 @@ RUN sed -i -e "/^mirrorlist/ d" \
 {% if base_distro == "centos" %}
 {% endraw %}
 
-## NOTE(yoctozepto): GPG key location is replaced for Percona repo only
 ## TODO(yoctozepto): CentOS hits external EPEL repo for its repo package (epel-release-*.rpm), should use the mirrored
 RUN sed -i \
         -e "/^mirrorlist/ d" \
@@ -46,7 +45,6 @@ RUN sed -i \
     && sed -i \
         -e "s|https://trunk.rdoproject.org|{{ nodepool_rdo_proxy }}|g" \
         -e "s|https://cbs.centos.org/repos|{{ nodepool_cbs_centos_proxy }}|g" \
-        -e "s|https://repo.percona.com|{{ nodepool_percona_proxy }}|g" \
         /etc/yum.repos.d/*.repo
 
 {% raw %}
@@ -56,7 +54,6 @@ RUN sed -i \
 ## TODO(yoctozepto): replace base repo earlier as well (like RHEL-based do)
 RUN sed -i -e "s|http://archive.ubuntu.com|http://{{ nodepool_mirror_host }}|" \
         -e "s|http://ubuntu-cloud.archive.canonical.com/ubuntu|http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|" \
-        -e "s|http://repo.percona.com|{{ nodepool_percona_proxy }}|" \
         /etc/apt/sources.list \
     && apt-get update
 
diff --git a/tests/vars/zuul.yml b/tests/vars/zuul.yml
index 68c35e69b6..524f38a607 100644
--- a/tests/vars/zuul.yml
+++ b/tests/vars/zuul.yml
@@ -4,4 +4,3 @@ nodepool_pypi_mirror: "http://{{ zuul_site_mirror_fqdn }}:8080/pypi/simple"
 nodepool_mirror_host: "{{ zuul_site_mirror_fqdn }}"
 nodepool_npmjs_proxy: "http://{{ zuul_site_mirror_fqdn }}:8080/registry.npmjs/"
 nodepool_cbs_centos_proxy: "http://{{ zuul_site_mirror_fqdn }}:8080/cbs.centos"
-nodepool_percona_proxy: "http://{{ zuul_site_mirror_fqdn }}:8080/percona"