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
This commit is contained in:
Mark Goddard 2024-03-21 12:41:18 +00:00
parent b8146efd1c
commit 667d153ef1
3 changed files with 28 additions and 5 deletions
ansible/roles/mariadb
defaults
tasks
releasenotes/notes

@ -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 %}"

@ -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

@ -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.