adds DB support for action retrying
this patch add extra parameter to db api for abandoning retrying actions. Change-Id: I034a7b0c791b54592695f740d1e8638d37d1b51c
This commit is contained in:
parent
495299c87f
commit
97c3416b99
|
@ -384,8 +384,8 @@ def action_acquire_random_ready(context, owner, timestamp):
|
|||
return IMPL.action_acquire_random_ready(context, owner, timestamp)
|
||||
|
||||
|
||||
def action_abandon(context, action_id):
|
||||
return IMPL.action_abandon(context, action_id)
|
||||
def action_abandon(context, action_id, values=None):
|
||||
return IMPL.action_abandon(context, action_id, values)
|
||||
|
||||
|
||||
def action_lock_check(context, action_id, owner=None):
|
||||
|
|
|
@ -1217,7 +1217,7 @@ def action_acquire_random_ready(context, owner, timestamp):
|
|||
return action
|
||||
|
||||
|
||||
def action_abandon(context, action_id):
|
||||
def action_abandon(context, action_id, values=None):
|
||||
'''Abandon an action for other workers to execute again.
|
||||
|
||||
This API is always called with the action locked by the current
|
||||
|
@ -1230,6 +1230,8 @@ def action_abandon(context, action_id):
|
|||
action.start_time = None
|
||||
action.status = consts.ACTION_READY
|
||||
action.status_reason = _('The action was abandoned.')
|
||||
if values:
|
||||
action.update(values)
|
||||
action.save(session)
|
||||
return action
|
||||
|
||||
|
|
|
@ -130,8 +130,8 @@ class Action(base.SenlinObject, base.VersionedObjectDictCompat):
|
|||
return db_api.action_acquire_random_ready(context, owner, timestamp)
|
||||
|
||||
@classmethod
|
||||
def abandon(cls, context, action_id):
|
||||
return db_api.action_abandon(context, action_id)
|
||||
def abandon(cls, context, action_id, values=None):
|
||||
return db_api.action_abandon(context, action_id, values)
|
||||
|
||||
@classmethod
|
||||
def signal(cls, context, action_id, value):
|
||||
|
|
|
@ -558,8 +558,9 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||
before_abandon = db_api.action_get(self.ctx, action.id)
|
||||
self.assertEqual(spec['owner'], before_abandon.owner)
|
||||
self.assertEqual(spec['start_time'], before_abandon.start_time)
|
||||
self.assertIsNone(before_abandon.data)
|
||||
|
||||
db_api.action_abandon(self.ctx, action.id)
|
||||
db_api.action_abandon(self.ctx, action.id, {})
|
||||
after_abandon = db_api.action_get(self.ctx, action.id)
|
||||
|
||||
self.assertIsNone(after_abandon.owner)
|
||||
|
@ -567,3 +568,27 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||
self.assertEqual('The action was abandoned.',
|
||||
after_abandon.status_reason)
|
||||
self.assertEqual(consts.ACTION_READY, after_abandon.status)
|
||||
self.assertIsNone(after_abandon.data)
|
||||
|
||||
def test_action_abandon_with_params(self):
|
||||
spec = {
|
||||
"owner": "test_owner",
|
||||
"start_time": 14506893904.0
|
||||
}
|
||||
action = _create_action(self.ctx, **spec)
|
||||
|
||||
before_abandon = db_api.action_get(self.ctx, action.id)
|
||||
self.assertEqual(spec['owner'], before_abandon.owner)
|
||||
self.assertEqual(spec['start_time'], before_abandon.start_time)
|
||||
self.assertIsNone(before_abandon.data)
|
||||
|
||||
db_api.action_abandon(self.ctx, action.id,
|
||||
{'data': {'retries': 1}})
|
||||
after_abandon = db_api.action_get(self.ctx, action.id)
|
||||
|
||||
self.assertIsNone(after_abandon.owner)
|
||||
self.assertIsNone(after_abandon.start_time)
|
||||
self.assertEqual('The action was abandoned.',
|
||||
after_abandon.status_reason)
|
||||
self.assertEqual(consts.ACTION_READY, after_abandon.status)
|
||||
self.assertEqual({'retries': 1}, after_abandon.data)
|
||||
|
|
Loading…
Reference in New Issue