From e8ee22ba7128fd9cc83656d5ba63d4a6d8877256 Mon Sep 17 00:00:00 2001 From: David Della Vecchia Date: Mon, 19 Oct 2015 20:35:57 +0000 Subject: [PATCH 1/2] fixing bug 1507619 --- hooks/keystone_hooks.py | 4 ++++ unit_tests/test_keystone_hooks.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hooks/keystone_hooks.py b/hooks/keystone_hooks.py index 5d3fd8b5..72927c31 100755 --- a/hooks/keystone_hooks.py +++ b/hooks/keystone_hooks.py @@ -121,6 +121,10 @@ def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() configure_installation_source(config('openstack-origin')) + + unison.ensure_user(user=SSH_USER, group='juju_keystone') + unison.ensure_user(user=SSH_USER, group='keystone') + status_set('maintenance', 'Installing apt packages') apt_update() apt_install(determine_packages(), fatal=True) diff --git a/unit_tests/test_keystone_hooks.py b/unit_tests/test_keystone_hooks.py index 70ade2e1..92bd7f7b 100644 --- a/unit_tests/test_keystone_hooks.py +++ b/unit_tests/test_keystone_hooks.py @@ -83,13 +83,15 @@ class KeystoneRelationTests(CharmTestCase): self.ssh_user = 'juju_keystone' @patch.object(utils, 'git_install_requested') - def test_install_hook(self, git_requested): + @patch.object(unison, 'ensure_user') + def test_install_hook(self, ensure_user, git_requested): git_requested.return_value = False repo = 'cloud:precise-grizzly' self.test_config.set('openstack-origin', repo) hooks.install() self.assertTrue(self.execd_preinstall.called) self.configure_installation_source.assert_called_with(repo) + ensure_user.assert_called_with(user=self.ssh_user, group='keystone') self.assertTrue(self.apt_update.called) self.apt_install.assert_called_with( ['apache2', 'haproxy', 'keystone', 'openssl', 'pwgen', @@ -98,7 +100,8 @@ class KeystoneRelationTests(CharmTestCase): self.git_install.assert_called_with(None) @patch.object(utils, 'git_install_requested') - def test_install_hook_git(self, git_requested): + @patch.object(unison, 'ensure_user') + def test_install_hook_git(self, ensure_user, git_requested): git_requested.return_value = True repo = 'cloud:trusty-juno' openstack_origin_git = { @@ -118,6 +121,7 @@ class KeystoneRelationTests(CharmTestCase): hooks.install() self.assertTrue(self.execd_preinstall.called) self.configure_installation_source.assert_called_with(repo) + ensure_user.assert_called_with(user=self.ssh_user, group='keystone') self.assertTrue(self.apt_update.called) self.apt_install.assert_called_with( ['apache2', 'haproxy', 'libffi-dev', 'libmysqlclient-dev', From a8a332f8c88fd059403146fca70cd14997611efa Mon Sep 17 00:00:00 2001 From: David Della Vecchia Date: Mon, 19 Oct 2015 20:52:06 +0000 Subject: [PATCH 2/2] reordering function calls to avoid race condition --- hooks/keystone_hooks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hooks/keystone_hooks.py b/hooks/keystone_hooks.py index 72927c31..83f4775d 100755 --- a/hooks/keystone_hooks.py +++ b/hooks/keystone_hooks.py @@ -121,10 +121,6 @@ def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() configure_installation_source(config('openstack-origin')) - - unison.ensure_user(user=SSH_USER, group='juju_keystone') - unison.ensure_user(user=SSH_USER, group='keystone') - status_set('maintenance', 'Installing apt packages') apt_update() apt_install(determine_packages(), fatal=True) @@ -132,6 +128,9 @@ def install(): status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) + unison.ensure_user(user=SSH_USER, group='juju_keystone') + unison.ensure_user(user=SSH_USER, group='keystone') + @hooks.hook('config-changed') @restart_on_change(restart_map())