Get cancellation grace period correctly

This changes the logic of getting cancellation grace
period of task runner before closing it: to move the
liveness check into the cancel_all() method in the
scheduler rather than ask the resource if it's IN_PROGRESS.

Change-Id: Ia2a03de227ff15cdce1b3dbb6cd6bff6c5a50a15
Partial-Bug: 1693495
This commit is contained in:
huangtianhua 2017-06-24 18:44:59 +08:00
parent 30c87bae3d
commit 8c62e96947
2 changed files with 4 additions and 4 deletions

View File

@ -1132,9 +1132,6 @@ class Resource(status.ResourceStatus):
properties.update_translation(rules, client_resolve=client_resolve)
def cancel_grace_period(self):
if self.status != self.IN_PROGRESS:
return None
canceller = getattr(self,
'handle_%s_cancel' % self.action.lower(),
None)

View File

@ -472,7 +472,10 @@ class DependencyTaskGroup(object):
return grace_period
for k, r in six.iteritems(self._runners):
gp = get_grace_period(k)
if not r.started() or r.done():
gp = None
else:
gp = get_grace_period(k)
try:
r.cancel(grace_period=gp)
except Exception as ex: