From fbb63e9538b3c4ea521839db4fc91257e7c06df2 Mon Sep 17 00:00:00 2001 From: Igor Kalnitsky Date: Thu, 14 Aug 2014 11:22:34 +0300 Subject: [PATCH] fuel_upgrade: run KillSupervisord hook in 5.0.1 Since we didn't backport a supervisor fix to 5.0.1, we should run our hook during upgrading from 5.0.1 too. Change-Id: I7b12cc537cf1e82f21cbac039e3480928cd24873 Implements: upgrade-to-5-1 --- .../pre_upgrade_hooks/from_5_0_to_any_kill_supervisord.py | 4 ++-- .../fuel_upgrade/tests/test_pre_upgrade_hooks.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/pre_upgrade_hooks/from_5_0_to_any_kill_supervisord.py b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/pre_upgrade_hooks/from_5_0_to_any_kill_supervisord.py index 32f5fcc0de..9f29dec2b3 100644 --- a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/pre_upgrade_hooks/from_5_0_to_any_kill_supervisord.py +++ b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/pre_upgrade_hooks/from_5_0_to_any_kill_supervisord.py @@ -38,7 +38,7 @@ class KillSupervisordHook(PreUpgradeHookBase): #: commands to kill supervisord commands = [ - 'kill -9 `cat /var/run/supervisord.pid`', + 'kill -9 `cat /var/run/supervisord.pid` || pkill -9 -P 1 supervisord', 'rm -f /var/run/supervisord.pid', 'pkill -f "docker.*D.*attach.*fuel-core"', 'pkill -f "dockerctl.*start.*attach"'] @@ -46,7 +46,7 @@ class KillSupervisordHook(PreUpgradeHookBase): def check_if_required(self): """The hack is required if we're going to upgrade from 5.0 to any. """ - return self.config.from_version in ('5.0', ) + return self.config.from_version in ('5.0', '5.0.1') def run(self): for command in self.commands: diff --git a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/tests/test_pre_upgrade_hooks.py b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/tests/test_pre_upgrade_hooks.py index 0ca310a88f..027ffc92ff 100644 --- a/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/tests/test_pre_upgrade_hooks.py +++ b/fuel_upgrade_system/fuel_upgrade/fuel_upgrade/tests/test_pre_upgrade_hooks.py @@ -214,6 +214,9 @@ class TestKillSupervisordHook(TestPreUpgradeHooksBase): self.hook.config.from_version = '5.0' self.assertTrue(self.hook.check_if_required()) + self.hook.config.from_version = '5.0.1' + self.assertTrue(self.hook.check_if_required()) + def test_is_required_returns_false(self): self.hook.config.from_version = '5.1' self.assertFalse(self.hook.check_if_required()) @@ -225,7 +228,8 @@ class TestKillSupervisordHook(TestPreUpgradeHooksBase): self.hook.run() exec_cmd.assert_has_calls([ - mock.call('kill -9 `cat /var/run/supervisord.pid`'), + mock.call('kill -9 `cat /var/run/supervisord.pid` ' + '|| pkill -9 -P 1 supervisord'), mock.call('rm -f /var/run/supervisord.pid'), mock.call('pkill -f "docker.*D.*attach.*fuel-core"'), mock.call('pkill -f "dockerctl.*start.*attach"')])