Is there a way where we can limit a specific action to be run repeatedly in a given time interval on the same host?
Are you trying to prevent the action from being run repeatedly?
I am trying to do something like , if a service keeps going down and I’m restarting it and it comes up and goes down again I’ll be stuck into a loop which I don’t want. If a service goes down like 10times within a minute maybe I should stop restarting it.
Here’s a possible solution . . . have your action insert a key into an object in the datastore when it runs, with a TTL set to your specific timeframe. Then check the number of keys in the object before you run the action. Or if it’s in a workflow, maybe do something else, like send an email. Hopefully the TTL documentation should make all clear.
You probably want to handle that logic within workflow while saving the state of execution result and control retry/limit logic there. @guymatz gave a good hint about utilizing K/V storage with TTL for this.
Besides of that, there is a somewhat similar feature request idea to add in StackStorm policies:
@armab I have created a policy for retrying timeout action as showing in doc but that policy is not working for workflows in stackstorm v3.1.0. Can you tell me why it is not working and what to do for making it as working in that version of stackstorm ?
Thanks in advance
@Balaji.p.s What is the documentation page you’re referring to?
Retry policy is not supported for action executions under workflows. Each specific workflow engine handles retries by its own means where applicable. Currently, action execution will retry on failure and timeout but workflow fails immediately.
Is there any way to rerun the timeout action in workflow of stackstorm v3.1.0 ?
Can we handle timeout actions by running that specific task in workflow in stackstorm v3.1.0 ?
I need as use that in my workflows which are developed in v3.1.0.
@armab I referred the page in stackstorm documentaion which I mentioned below. whille saving the policy it is not giving any error and not triggering when it’s criteria meets.
--- name: http.retry description: Retry core.http action on timeout. enabled: true resource_ref: core.http policy_type: action.retry parameters: retry_on: timeout max_retry_count: 2 delay: 2