diff --git a/mistral/services/expiration_policy.py b/mistral/services/expiration_policy.py index 6a2d5cb0c..c30c7d90c 100644 --- a/mistral/services/expiration_policy.py +++ b/mistral/services/expiration_policy.py @@ -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 diff --git a/mistral/services/periodic.py b/mistral/services/periodic.py index ed2066d27..a157cb8dd 100644 --- a/mistral/services/periodic.py +++ b/mistral/services/periodic.py @@ -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) diff --git a/mistral/services/triggers.py b/mistral/services/triggers.py index 158b9aea6..65d1fe54c 100644 --- a/mistral/services/triggers.py +++ b/mistral/services/triggers.py @@ -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.' ) diff --git a/mistral/workflow/with_items.py b/mistral/workflow/with_items.py index 0e07021e3..33558aeb9 100644 --- a/mistral/workflow/with_items.py +++ b/mistral/workflow/with_items.py @@ -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})