From 38c9cb1ab7d51f07104bafc074e353faaa2cdb4b Mon Sep 17 00:00:00 2001 From: Eli Qiao Date: Fri, 23 Oct 2015 16:10:57 +0800 Subject: [PATCH] Fix exception when create bay failed Fix Wrong usage of bay object when create bay failed, stack_status should be should from stack. Closes-Bug: #1509236 Change-Id: Ieea0c990853d49876f4bbf850c8f6aaa6cef9683 --- magnum/conductor/handlers/bay_conductor.py | 6 +++--- magnum/tests/unit/conductor/handlers/test_bay_conductor.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/magnum/conductor/handlers/bay_conductor.py b/magnum/conductor/handlers/bay_conductor.py index c195f94b82..ab88c77012 100644 --- a/magnum/conductor/handlers/bay_conductor.py +++ b/magnum/conductor/handlers/bay_conductor.py @@ -240,7 +240,7 @@ class HeatPoller(object): if stack.stack_status in (bay_status.CREATE_FAILED, bay_status.DELETE_FAILED, bay_status.UPDATE_FAILED): - self._bay_failed() + self._bay_failed(stack) raise loopingcall.LoopingCallDone() # only check max attempts when the stack is being created when # the timeout hasn't been set. If the timeout has been set then @@ -291,10 +291,10 @@ class HeatPoller(object): self.bay.node_count = stack.parameters[stack_nc_param] self.bay.save() - def _bay_failed(self): + def _bay_failed(self, stack): LOG.error(_LE('Bay error, stack status: %(bay_status)s, ' 'stack_id: %(stack_id)s, ' 'reason: %(reason)s') % - {'bay_status': self.bay.stack_status, + {'bay_status': stack.stack_status, 'stack_id': self.bay.stack_id, 'reason': self.bay.status_reason}) diff --git a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py index ae21dbb4f8..6b55ceaa72 100644 --- a/magnum/tests/unit/conductor/handlers/test_bay_conductor.py +++ b/magnum/tests/unit/conductor/handlers/test_bay_conductor.py @@ -376,5 +376,5 @@ class TestHeatPoller(base.TestCase): @patch('magnum.conductor.handlers.bay_conductor.LOG') def test_bay_failed(self, logger): mock_heat_stack, bay, poller = self.setup_poll_test() - poller._bay_failed() + poller._bay_failed(mock_heat_stack) self.assertEqual(1, logger.error.call_count)