Fix backup using customized container image registry

Change-Id: Ib35743e1c315bb7fd4d0fbd99eaa409a4bf5c792
Story: 2008996
Task: 42658
This commit is contained in:
Lingxian Kong 2021-06-21 09:03:56 +12:00
parent 189d3493a8
commit 6d2ab68a8a
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- Fixed backup creation failed issue when using custom container image
registry.

View File

@ -67,7 +67,7 @@ class MySqlApp(service.BaseMySqlApp):
to openstacktrove/db-backup-mysql5.7:1.0.0
"""
image = cfg.get_configuration_property('backup_docker_image')
name, tag = image.split(':', 1)
name, tag = image.rsplit(':', 1)
# Get minor version
cur_ver = semantic_version.Version.coerce(CONF.datastore_version)

View File

@ -91,11 +91,16 @@ def run_container(client, image, name, network_mode="host", volumes={},
"""
try:
container = client.containers.get(name)
LOG.debug(f'Removing existing container {name}')
container.remove(force=True)
except docker.errors.NotFound:
pass
try:
LOG.info(
f'Running container {name}, image: {image}, '
f'network_mode: {network_mode}, volumes: {volumes}, '
f'command: {command}')
output = client.containers.run(
image,
name=name,