Fix undercloud backup via tripleoclient
The move to containerized deployment introduced a regression that mistral executor service does not have access to undercloud host any more because it runs in container. This patch and it's dependencies are fixing this issue by: - using remote connection during DB backup - using volume mounts during filesystem backup For details see following patches. Change-Id: I8726187da444b55832bc2741da66ab7240e7bc3e Depends-On: Ia1fd60a13570a42f5243beb5bb0487c743e31d27 Depends-On: I67899db3c1f4197210bc362a8f944529a3a7b2b3 Closes-Bug: #1812960
This commit is contained in:
@@ -87,8 +87,9 @@ class CreateDatabaseBackup(base.Action):
|
||||
the result in a given folder.
|
||||
"""
|
||||
|
||||
def __init__(self, path, dbuser, dbpassword):
|
||||
def __init__(self, path, dbhost, dbuser, dbpassword):
|
||||
self.path = path
|
||||
self.dbhost = dbhost
|
||||
self.dbuser = dbuser
|
||||
self.dbpassword = dbpassword
|
||||
self.backup_name = os.path.join(self.path,
|
||||
@@ -108,11 +109,13 @@ class CreateDatabaseBackup(base.Action):
|
||||
# Backup all databases with nice and ionice just not to create
|
||||
# a huge load on undercloud. Output will be redirected to mysqldump
|
||||
# variable and will be gzipped.
|
||||
script = """
|
||||
#!/bin/bash
|
||||
nice -n 19 ionice -c2 -n7 \
|
||||
mysqldump -u%s -p%s --opt --all-databases | gzip > %s
|
||||
""" % (self.dbuser, self.dbpassword, self.backup_name)
|
||||
strlocals = self.__dict__
|
||||
script = ("#!/bin/bash\n"
|
||||
"nice -n 19 ionice -c2 -n7 \\\n"
|
||||
" mysqldump -h'%(dbhost)s' \\\n"
|
||||
" -u'%(dbuser)s' -p'%(dbpassword)s' \\\n"
|
||||
" --opt --all-databases |\\\n"
|
||||
" gzip > %(backup_name)s\n") % strlocals
|
||||
|
||||
proc_failed = False
|
||||
|
||||
|
@@ -76,7 +76,7 @@ class CreateDatabaseBackupTest(base.TestCase):
|
||||
super(CreateDatabaseBackupTest, self).setUp()
|
||||
self.dbback = undercloud.CreateDatabaseBackup(
|
||||
'/var/tmp/undercloud-backup-dG6hr_',
|
||||
'root', 'dbpassword')
|
||||
'127.0.0.1', 'root', 'dbpassword')
|
||||
|
||||
@mock.patch(
|
||||
'tripleo_common.actions.base.TripleOAction.get_object_client')
|
||||
@@ -85,12 +85,12 @@ class CreateDatabaseBackupTest(base.TestCase):
|
||||
self, mock_check_call, mock_get_object_client):
|
||||
self.dbback.logger = mock.Mock()
|
||||
self.dbback.run(mock_get_object_client)
|
||||
assert_string = ('\n #!/bin/bash\n '
|
||||
'nice -n 19 ionice -c2 -n7 '
|
||||
'mysqldump -uroot -pdbpassword --opt '
|
||||
'--all-databases | gzip > ' +
|
||||
self.dbback.backup_name +
|
||||
'\n ')
|
||||
assert_string = ("#!/bin/bash\n"
|
||||
"nice -n 19 ionice -c2 -n7 \\\n"
|
||||
" mysqldump -h'127.0.0.1' \\\n"
|
||||
" -u'root' -p'dbpassword' \\\n"
|
||||
" --opt --all-databases |\\\n"
|
||||
" gzip > %s\n" % self.dbback.backup_name)
|
||||
mock_check_call.assert_called_once_with(assert_string, shell=True)
|
||||
|
||||
|
||||
|
@@ -10,7 +10,7 @@ workflows:
|
||||
tags:
|
||||
- tripleo-common-managed
|
||||
input:
|
||||
- sources_path: '/home/stack/'
|
||||
- sources_path: '/backup'
|
||||
- queue_name: tripleo
|
||||
tasks:
|
||||
# Action to know if there is enough available space
|
||||
@@ -49,6 +49,7 @@ workflows:
|
||||
publish:
|
||||
status: SUCCESS
|
||||
message: <% task().result %>
|
||||
undercloud_db_host: <% task().result.variables.undercloud_db_host %>
|
||||
undercloud_db_password: <% task().result.variables.undercloud_db_password %>
|
||||
on-success: create_database_backup
|
||||
on-error: send_message
|
||||
@@ -61,6 +62,7 @@ workflows:
|
||||
create_database_backup:
|
||||
input:
|
||||
path: <% $.backup_path.path %>
|
||||
dbhost: <% $.undercloud_db_host %>
|
||||
dbuser: root
|
||||
dbpassword: <% $.undercloud_db_password %>
|
||||
action: tripleo.undercloud.create_database_backup
|
||||
|
Reference in New Issue
Block a user