Merge "Avoid comparision between "None" type and "int" type."

This commit is contained in:
Jenkins 2015-10-28 12:40:32 +00:00 committed by Gerrit Code Review
commit f7ee8114e2
4 changed files with 11 additions and 9 deletions

View File

@ -43,7 +43,7 @@ class ExecutionExpirationPolicy(periodic_task.PeriodicTasks):
interval = CONF.execution_expiration_policy.evaluation_interval
older_than = CONF.execution_expiration_policy.older_than
if (interval and older_than >= 1):
if (interval and older_than and older_than >= 1):
_periodic_task = periodic_task.periodic_task(
spacing=interval * 60,
run_immediately=True

View File

@ -51,7 +51,8 @@ class MistralPeriodicTasks(periodic_task.PeriodicTasks):
**t.workflow_params
)
finally:
if t.remaining_executions > 0:
if (t.remaining_executions is not None and
t.remaining_executions > 0):
t.remaining_executions -= 1
if t.remaining_executions == 0:
db_api_v2.delete_cron_trigger(t.name)

View File

@ -45,7 +45,7 @@ def validate_cron_trigger_input(pattern, first_time, count):
raise exc.InvalidModelException(
'first_execution_time must be at least 1 second in the future.'
)
if not pattern and count > 1:
if not pattern and count and count > 1:
raise exc.InvalidModelException(
'Pattern must be provided if count is superior to 1.'
)

View File

@ -111,12 +111,13 @@ def get_indices_for_loop(task_ex):
def decrease_capacity(task_ex, count):
with_items_context = _get_context(task_ex)
if with_items_context[_CAPACITY] >= count:
with_items_context[_CAPACITY] -= count
elif with_items_context[_CAPACITY]:
raise exc.WorkflowException(
"Impossible to apply current with-items concurrency."
)
if with_items_context[_CAPACITY] is not None:
if with_items_context[_CAPACITY] >= count:
with_items_context[_CAPACITY] -= count
else:
raise exc.WorkflowException(
"Impossible to apply current with-items concurrency."
)
task_ex.runtime_context.update({_WITH_ITEMS: with_items_context})