Merge "Use host network for db_sync"

This commit is contained in:
Zuul 2022-09-12 15:51:10 +00:00 committed by Gerrit Code Review
commit 85c50ca3de
2 changed files with 13 additions and 8 deletions

View File

@ -375,6 +375,7 @@ class HeatContainerLauncher(HeatBaseLauncher):
cmd = [ cmd = [
'podman', 'run', '--rm', 'podman', 'run', '--rm',
'--net', 'host',
'--user', self.user, '--user', self.user,
'--volume', '%(conf)s:/etc/heat/heat.conf:Z' % {'conf': '--volume', '%(conf)s:/etc/heat/heat.conf:Z' % {'conf':
self.config_file}, self.config_file},
@ -388,6 +389,7 @@ class HeatContainerLauncher(HeatBaseLauncher):
def get_heat_uid(self): def get_heat_uid(self):
cmd = [ cmd = [
'podman', 'run', '--rm', 'podman', 'run', '--rm',
'--net', 'host',
self.all_container_image, self.all_container_image,
'getent', 'passwd', self.user 'getent', 'passwd', self.user
] ]
@ -402,6 +404,7 @@ class HeatContainerLauncher(HeatBaseLauncher):
def get_heat_gid(self): def get_heat_gid(self):
cmd = [ cmd = [
'podman', 'run', '--rm', 'podman', 'run', '--rm',
'--net', 'host',
self.all_container_image, self.all_container_image,
'getent', 'group', self.user 'getent', 'group', self.user
] ]
@ -546,6 +549,7 @@ class HeatPodLauncher(HeatContainerLauncher):
cmd = [ cmd = [
'sudo', 'podman', 'run', '--rm', 'sudo', 'podman', 'run', '--rm',
'--user', 'heat', '--user', 'heat',
'--net', 'host',
'--volume', '%(conf)s:/etc/heat/heat.conf:z' % {'conf': '--volume', '%(conf)s:/etc/heat/heat.conf:z' % {'conf':
self.config_file}, self.config_file},
'--volume', '%(inst_tmp)s:%(inst_tmp)s:z' % {'inst_tmp': '--volume', '%(inst_tmp)s:%(inst_tmp)s:z' % {'inst_tmp':

View File

@ -136,8 +136,8 @@ class TestHeatPodLauncher(base.TestCase):
mock.call(['chcon', '-R', '-t', 'container_file_t', '-l', 's0', mock.call(['chcon', '-R', '-t', 'container_file_t', '-l', 's0',
mock.ANY]), mock.ANY]),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat', mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY, '--net', 'host', '--volume', mock.ANY, '--volume',
mock.ANY, 'heat-manage', 'db_sync']) mock.ANY, mock.ANY, 'heat-manage', 'db_sync'])
] ]
self.assertEqual(self.check_call.mock_calls, calls) self.assertEqual(self.check_call.mock_calls, calls)
self.assertFalse(mock_do_restore_db.called) self.assertFalse(mock_do_restore_db.called)
@ -147,8 +147,9 @@ class TestHeatPodLauncher(base.TestCase):
mock_db_exists.return_value = True mock_db_exists.return_value = True
launcher.heat_db_sync(restore_db=True) launcher.heat_db_sync(restore_db=True)
self.check_call.assert_called_once_with([ self.check_call.assert_called_once_with([
'sudo', 'podman', 'run', '--rm', '--user', 'heat', '--volume', 'sudo', 'podman', 'run', '--rm', '--user', 'heat', '--net', 'host',
mock.ANY, '--volume', mock.ANY, mock.ANY, 'heat-manage', 'db_sync' '--volume', mock.ANY, '--volume', mock.ANY, mock.ANY,
'heat-manage', 'db_sync'
]) ])
self.assertTrue(mock_do_restore_db.called) self.assertTrue(mock_do_restore_db.called)
@ -167,8 +168,8 @@ class TestHeatPodLauncher(base.TestCase):
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql', mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'flush privileges;']), 'mysql', '-e', 'flush privileges;']),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat', mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY, '--net', 'host', '--volume', mock.ANY, '--volume',
mock.ANY, 'heat-manage', 'db_sync']) mock.ANY, mock.ANY, 'heat-manage', 'db_sync'])
] ]
self.assertEqual(self.check_call.mock_calls, calls) self.assertEqual(self.check_call.mock_calls, calls)
self.assertTrue(mock_do_restore_db.called) self.assertTrue(mock_do_restore_db.called)
@ -189,8 +190,8 @@ class TestHeatPodLauncher(base.TestCase):
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql', mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'flush privileges;']), 'mysql', '-e', 'flush privileges;']),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat', mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY, '--net', 'host', '--volume', mock.ANY, '--volume',
mock.ANY, 'heat-manage', 'db_sync']) mock.ANY, mock.ANY, 'heat-manage', 'db_sync'])
] ]
self.assertEqual(self.check_call.mock_calls, calls) self.assertEqual(self.check_call.mock_calls, calls)
self.assertFalse(mock_do_restore_db.called) self.assertFalse(mock_do_restore_db.called)