Hello everyone,
I am working on a Google Workflow where each retry should trigger a specific action:
To achieve this, I tried using the native try...except syntax along with a retry block. The goal is to handle each retry individually and execute a specific step based on the retry number.
Despite my efforts, the following issues occur:
Specific actions for retries do not execute as expected:
Use of execution.retry_attempt:
Manual Incrementation with a Variable (retry_count):
Here is a simplified example of my workflow:
main:
params: [input]
steps:
- init_retries:
assign:
- retry_count: 0 # Initialize retry counter
- simulate_error_and_alert:
try:
steps:
- simulate_error:
call: http.get
args:
url: "https://httpstat.us/500" # Simulate an HTTP error
except:
steps:
- handle_alert_action:
switch:
- condition: ${retry_count == 0} # Retry 1
next: send_email_service_1
- condition: ${retry_count == 1} # Retry 2
next: send_email_service_2
- condition: ${retry_count == 2} # Retry 3
next: create_incident
- increment_retry_count:
assign:
- retry_count: ${retry_count + 1} # Increment retry counter
retry:
predicate: ${http.default_retry_predicate}
max_retries: 3
backoff:
initial_delay: 5 # 5 seconds
max_delay: 10 # 10 seconds
multiplier: 2
- send_email_service_1:
call: sys.log
args:
text: "Retry 1: Sending email to Service 1."
severity: "INFO"
- send_email_service_2:
call: sys.log
args:
text: "Retry 2: Sending email to Service 2."
severity: "INFO"
- create_incident:
call: sys.log
args:
text: "Retry 3: Creating an incident."
severity: "CRITICAL"
- log_final_failure:
call: sys.log
args:
text: "Retries exhausted. Workflow failed."
severity: "ERROR"
Thank you in advance for your help and feedback! 😊