Concurrency policy not running if set to one
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
SUMMARY
If you were to set the concurrency policy of an action to be 1 then it does not run any actions. I believe the following piece of code is responsible:
count = scheduled + running
# Mark the execution as scheduled if threshold is not reached or delayed otherwise.
if count < self.threshold:
LOG.debug(
"There are %s instances of %s in scheduled or running status. "
"Threshold of %s is not reached. Action execution will be scheduled.",
count,
target.action,
self._policy_ref,
)
status = action_constants.LIVEACTION_STATUS_REQUESTED
else:
action = "delayed" if self.policy_action == "delay" else "canceled"
LOG.debug(
"There are %s instances of %s in scheduled or running status. "
"Threshold of %s is reached. Action execution will be %s.",
count,
target.action,
self._policy_ref,
action,
)
status = self._get_status_for_policy_action(action=self.policy_action)
I think this should be changed to:
count = scheduled + running
# Mark the execution as scheduled if threshold is not reached or delayed otherwise.
if count <= self.threshold:
LOG.debug(
"There are %s instances of %s in scheduled or running status. "
"Threshold of %s is not reached. Action execution will be scheduled.",
count,
target.action,
self._policy_ref,
)
status = action_constants.LIVEACTION_STATUS_REQUESTED
else:
action = "delayed" if self.policy_action == "delay" else "canceled"
LOG.debug(
"There are %s instances of %s in scheduled or running status. "
"Threshold of %s is reached. Action execution will be %s.",
count,
target.action,
self._policy_ref,
action,
)
status = self._get_status_for_policy_action(action=self.policy_action)
and a unit test should be added.
Steps to reproduce the problem
Set the policy to be 1 for a specific action in stackstorm, and try to run the action using something like with items.
Expected Results
One action running at a time.
Actual Results
No actions run and they stay in the policy_action state.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in st2actions/st2actions/policies/concurrency.py at the threshold comparison linked in the issue. Add a unit test covering a concurrency policy of 1, then verify that one action runs at a time and additional executions receive the configured policy action instead of all remaining stuck.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100