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.
|
the result in a given folder.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, path, dbuser, dbpassword):
|
def __init__(self, path, dbhost, dbuser, dbpassword):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.dbhost = dbhost
|
||||||
self.dbuser = dbuser
|
self.dbuser = dbuser
|
||||||
self.dbpassword = dbpassword
|
self.dbpassword = dbpassword
|
||||||
self.backup_name = os.path.join(self.path,
|
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
|
# Backup all databases with nice and ionice just not to create
|
||||||
# a huge load on undercloud. Output will be redirected to mysqldump
|
# a huge load on undercloud. Output will be redirected to mysqldump
|
||||||
# variable and will be gzipped.
|
# variable and will be gzipped.
|
||||||
script = """
|
strlocals = self.__dict__
|
||||||
#!/bin/bash
|
script = ("#!/bin/bash\n"
|
||||||
nice -n 19 ionice -c2 -n7 \
|
"nice -n 19 ionice -c2 -n7 \\\n"
|
||||||
mysqldump -u%s -p%s --opt --all-databases | gzip > %s
|
" mysqldump -h'%(dbhost)s' \\\n"
|
||||||
""" % (self.dbuser, self.dbpassword, self.backup_name)
|
" -u'%(dbuser)s' -p'%(dbpassword)s' \\\n"
|
||||||
|
" --opt --all-databases |\\\n"
|
||||||
|
" gzip > %(backup_name)s\n") % strlocals
|
||||||
|
|
||||||
proc_failed = False
|
proc_failed = False
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ class CreateDatabaseBackupTest(base.TestCase):
|
|||||||
super(CreateDatabaseBackupTest, self).setUp()
|
super(CreateDatabaseBackupTest, self).setUp()
|
||||||
self.dbback = undercloud.CreateDatabaseBackup(
|
self.dbback = undercloud.CreateDatabaseBackup(
|
||||||
'/var/tmp/undercloud-backup-dG6hr_',
|
'/var/tmp/undercloud-backup-dG6hr_',
|
||||||
'root', 'dbpassword')
|
'127.0.0.1', 'root', 'dbpassword')
|
||||||
|
|
||||||
@mock.patch(
|
@mock.patch(
|
||||||
'tripleo_common.actions.base.TripleOAction.get_object_client')
|
'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, mock_check_call, mock_get_object_client):
|
||||||
self.dbback.logger = mock.Mock()
|
self.dbback.logger = mock.Mock()
|
||||||
self.dbback.run(mock_get_object_client)
|
self.dbback.run(mock_get_object_client)
|
||||||
assert_string = ('\n #!/bin/bash\n '
|
assert_string = ("#!/bin/bash\n"
|
||||||
'nice -n 19 ionice -c2 -n7 '
|
"nice -n 19 ionice -c2 -n7 \\\n"
|
||||||
'mysqldump -uroot -pdbpassword --opt '
|
" mysqldump -h'127.0.0.1' \\\n"
|
||||||
'--all-databases | gzip > ' +
|
" -u'root' -p'dbpassword' \\\n"
|
||||||
self.dbback.backup_name +
|
" --opt --all-databases |\\\n"
|
||||||
'\n ')
|
" gzip > %s\n" % self.dbback.backup_name)
|
||||||
mock_check_call.assert_called_once_with(assert_string, shell=True)
|
mock_check_call.assert_called_once_with(assert_string, shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ workflows:
|
|||||||
tags:
|
tags:
|
||||||
- tripleo-common-managed
|
- tripleo-common-managed
|
||||||
input:
|
input:
|
||||||
- sources_path: '/home/stack/'
|
- sources_path: '/backup'
|
||||||
- queue_name: tripleo
|
- queue_name: tripleo
|
||||||
tasks:
|
tasks:
|
||||||
# Action to know if there is enough available space
|
# Action to know if there is enough available space
|
||||||
@@ -49,6 +49,7 @@ workflows:
|
|||||||
publish:
|
publish:
|
||||||
status: SUCCESS
|
status: SUCCESS
|
||||||
message: <% task().result %>
|
message: <% task().result %>
|
||||||
|
undercloud_db_host: <% task().result.variables.undercloud_db_host %>
|
||||||
undercloud_db_password: <% task().result.variables.undercloud_db_password %>
|
undercloud_db_password: <% task().result.variables.undercloud_db_password %>
|
||||||
on-success: create_database_backup
|
on-success: create_database_backup
|
||||||
on-error: send_message
|
on-error: send_message
|
||||||
@@ -61,6 +62,7 @@ workflows:
|
|||||||
create_database_backup:
|
create_database_backup:
|
||||||
input:
|
input:
|
||||||
path: <% $.backup_path.path %>
|
path: <% $.backup_path.path %>
|
||||||
|
dbhost: <% $.undercloud_db_host %>
|
||||||
dbuser: root
|
dbuser: root
|
||||||
dbpassword: <% $.undercloud_db_password %>
|
dbpassword: <% $.undercloud_db_password %>
|
||||||
action: tripleo.undercloud.create_database_backup
|
action: tripleo.undercloud.create_database_backup
|
||||||
|
Reference in New Issue
Block a user