From 667d153ef1668f48566f3ed7e2846649b36dea5e Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 21 Mar 2024 12:41:18 +0000 Subject: [PATCH] Use the running MariaDB server image for backups If the container image used by Mariabackup is different than the one used by MariaDB server, it's possible that mariabackup and mariadb are incompatible. This may cause backup operations to fail. This change queries the running MariaDB server container's image and uses it when taking a backup. If MariaDB server isn't running on the host it falls back to the image defined in configuration. The separate mariabackup_image, mariabackup_tag and mariabackup_image_full variables are no longer required and have been removed. Closes-Bug: #2058644 Change-Id: I45f3f90ec1973dae92131ea16a7b248ab7a8ae69 --- ansible/roles/mariadb/defaults/main.yml | 4 ---- ansible/roles/mariadb/tasks/backup.yml | 14 +++++++++++++- .../notes/bug-2058644-1db8786303234787.yaml | 15 +++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/bug-2058644-1db8786303234787.yaml diff --git a/ansible/roles/mariadb/defaults/main.yml b/ansible/roles/mariadb/defaults/main.yml index eaa318963b..8adb3e7403 100644 --- a/ansible/roles/mariadb/defaults/main.yml +++ b/ansible/roles/mariadb/defaults/main.yml @@ -120,10 +120,6 @@ mariadb_wsrep_extra_provider_options: [] #################### # Backups #################### -mariabackup_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/mariadb-server" -mariabackup_tag: "{{ mariadb_tag }}" -mariabackup_image_full: "{{ mariabackup_image }}:{{ mariabackup_tag }}" - mariadb_backup_host: "{{ groups[mariadb_shard_group][0] }}" mariadb_backup_database_schema: "PERCONA_SCHEMA" mariadb_backup_database_user: "{% if mariadb_loadbalancer == 'haproxy' %}backup{% else %}{{ mariadb_shard_backup_user_prefix }}{{ mariadb_shard_id | string }}{% endif %}" diff --git a/ansible/roles/mariadb/tasks/backup.yml b/ansible/roles/mariadb/tasks/backup.yml index ef78107eb6..300581bc60 100644 --- a/ansible/roles/mariadb/tasks/backup.yml +++ b/ansible/roles/mariadb/tasks/backup.yml @@ -1,4 +1,13 @@ --- +- name: Get MariaDB container facts + become: true + kolla_container_facts: + container_engine: "{{ kolla_container_engine }}" + name: + - "{{ mariadb_services.mariadb.container_name }}" + check_mode: false + register: container_facts + - name: Taking {{ mariadb_backup_type }} database backup via Mariabackup become: true kolla_container: @@ -6,7 +15,10 @@ command: "bash -c 'sudo -E kolla_set_configs && /usr/local/bin/kolla_mariadb_backup.sh'" common_options: "{{ docker_common_options }}" detach: False - image: "{{ mariabackup_image_full }}" + # NOTE(mgoddard): Try to use the same image as the MariaDB server container + # to avoid compatibility issues. See + # https://bugs.launchpad.net/kolla-ansible/+bug/2058644. + image: "{{ container_facts.mariadb.Image | default(mariadb_services.mariadb.image) }}" name: "mariabackup" restart_policy: oneshot remove_on_exit: True diff --git a/releasenotes/notes/bug-2058644-1db8786303234787.yaml b/releasenotes/notes/bug-2058644-1db8786303234787.yaml new file mode 100644 index 0000000000..ec1286d322 --- /dev/null +++ b/releasenotes/notes/bug-2058644-1db8786303234787.yaml @@ -0,0 +1,15 @@ +--- +upgrade: + - | + MariaDB backup now uses the same image as the running MariaDB server. The + following variables relating to MariaDB backups are no longer used and have + been removed: + + * ``mariabackup_image`` + * ``mariabackup_tag`` + * ``mariabackup_image_full`` +fixes: + - | + Modifies the MariaDB procedure to use the same container image as the + running MariaDB server container. This should prevent compatibility issues + that may cause the backup to fail.