Hi, I had a question related to automations. I hav...
# prefect-cloud
k
Hi, I had a question related to automations. I have a use case wherein if a flow run stays in a
pending
state for >5 min, I need to 1. send a slack notification 2. cancel the flow run 3. Create a new deployment for the same flow with the same paylaod I could get the first 2 steps working fine, but I’m stuck on the third step. If I add an action that says
Run a deployment
and set it to
Infer Deployment
, I don’t see a way for me to specify for it to use the same payload that was passed into the flow run that was just cancelled. Can someone please guide me on how to go about this. Thanks
a
Hey Karthik! To make sure I understand — automations or not — you’re looking for “if this thing takes too long in pending, let me know and rerun it?
k
Correct
c
Thanks for reaching out, Karthik! I think there may be a gap here because when we're executing a
RunDeployment
action, we don't (currently) have access to the parameters from the prior flow run. Let me look into another avenue with the
AwaitingRetry
state to see if it would work for you, that may be a good alternative.
Okay, @Karthik, I think I have something that could work for you! Instead of cancelling the flow run and then re-running the deployment, would it work for your use case to retry the same flow run? I just spiked this out with an automation that looks like this:
This is using our general-purpose "Change flow run's state" Action (
change-flow-run-state
) and picking the state type
SCHEDULED
and using the name
AwaitingRetry
(this matches Prefect's retrying state). When I do this and cause my worker to crash while a flow is pending, the automation puts it right back to
AwaitingRetry
after the time expires, then the same flow run attempts to run again. This will carry all of the flow run's information with it, like the parameters, infrastructure configuration, etc.
If this would make sense for your use case, we can add a
RetryFlowRun
action that does this for you so it's just a simple choice from the dropdown
k
@Chris Guidry this seems to be working for my use case, thank you so much
c
Great to hear, Karthik! Let us know if you hit any snags