exception when running 'watcher actionplan start XXX'

In DefaultApplier.execute(), Action.list should set eager=True.
Otherwise it will trigger an exception when the notification is sent.

This also causes the FAILURE of
gate-watcher-dsvm-multinode-ubuntu-xenial-nv.

Change-Id: I27db9691727671abb582d4f22283ebda5bd51b07
Closes-Bug: #1676308
This commit is contained in:
licanwei 2017-03-28 12:36:34 +08:00
parent ca3d367ac7
commit 527423a5fa
2 changed files with 12 additions and 4 deletions

3
watcher/applier/default.py Normal file → Executable file
View File

@ -58,5 +58,6 @@ class DefaultApplier(base.BaseApplier):
LOG.debug("Executing action plan %s ", action_plan_uuid)
filters = {'action_plan_uuid': action_plan_uuid}
actions = objects.Action.list(self.context, filters=filters)
actions = objects.Action.list(self.context, filters=filters,
eager=True)
return self.engine.execute(actions)

View File

@ -40,9 +40,16 @@ class TestDefaultActionPlanHandler(base.DbTestCase):
self.addCleanup(p_action_plan_notifications.stop)
obj_utils.create_test_goal(self.context)
obj_utils.create_test_strategy(self.context)
obj_utils.create_test_audit(self.context)
self.action_plan = obj_utils.create_test_action_plan(self.context)
self.strategy = obj_utils.create_test_strategy(self.context)
self.audit = obj_utils.create_test_audit(
self.context, strategy_id=self.strategy.id)
self.action_plan = obj_utils.create_test_action_plan(
self.context, audit_id=self.audit.id,
strategy_id=self.strategy.id)
self.action = obj_utils.create_test_action(
self.context, action_plan_id=self.action_plan.id,
action_type='nop',
input_parameters={'message': 'hello World'})
@mock.patch.object(objects.ActionPlan, "get_by_uuid")
def test_launch_action_plan(self, m_get_action_plan):