Skip to content

Commit 1b387a3

Browse files
committed
Testing workflow retry
1 parent 879848d commit 1b387a3

File tree

3 files changed

+73
-9
lines changed

3 files changed

+73
-9
lines changed

modules/data_warehouse/bigquery.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,6 @@ resource "google_bigquery_data_transfer_config" "dts_config" {
372372
depends_on = [
373373
google_project_iam_member.dts_roles,
374374
google_bigquery_dataset.ds_edw,
375-
time_sleep.wait_after_workflow_execution
375+
time_sleep.complete_workflow
376376
]
377377
}

modules/data_warehouse/main.tf

-8
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,3 @@ resource "google_storage_bucket" "raw_bucket" {
8888

8989
labels = var.labels
9090
}
91-
92-
# Sleep for 120 seconds to allow the workflow to execute and finish setup
93-
resource "time_sleep" "wait_after_workflow_execution" {
94-
create_duration = "120s"
95-
depends_on = [
96-
data.http.call_workflows_setup,
97-
]
98-
}

modules/data_warehouse/workflows.tf

+72
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,75 @@ data "http" "call_workflows_setup" {
9898
google_service_account_iam_member.workflow_auth_function
9999
]
100100
}
101+
102+
# Sleep for 120 seconds to allow the workflow to execute and finish setup
103+
resource "time_sleep" "wait_after_workflow_execution" {
104+
create_duration = "120s"
105+
depends_on = [
106+
data.http.call_workflows_setup,
107+
]
108+
}
109+
110+
## Trigger the execution of the setup workflow with an API call
111+
data "http" "call_workflows_state_1" {
112+
url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
113+
method = "GET"
114+
request_headers = {
115+
Accept = "application/json"
116+
Authorization = "Bearer ${data.google_client_config.current.access_token}" }
117+
depends_on = [
118+
time_sleep.wait_after_workflow_execution,
119+
]
120+
}
121+
122+
data "http" "retry_workflows_1" {
123+
count = data.http.call_workflows_state_1.executions[0].state == "SUCCEEDED" || data.http.call_workflows_state_1.executions[0].state == "ACTIVE" ? 0 : 1
124+
url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
125+
method = "POST"
126+
request_headers = {
127+
Accept = "application/json"
128+
Authorization = "Bearer ${data.google_client_config.current.access_token}" }
129+
depends_on = [
130+
data.http.call_workflows_state_1]
131+
}
132+
133+
# # Sleep for 30 seconds to recheck the workflow state
134+
# resource "time_sleep" "wait_to_recheck_workflow" {
135+
# create_duration = "30s"
136+
# depends_on = [
137+
# data.http.retry_workflows_1,
138+
# ]
139+
# }
140+
141+
# ## Trigger the execution of the setup workflow with an API call
142+
# data "http" "call_workflows_state_2" {
143+
# count = data.http.call_workflows_state_2.executions[0].state == "SUCCEEDED" || data.http.call_workflows_state_2.executions[0].state == "ACTIVE" ? 0 : 1
144+
# url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
145+
# method = "GET"
146+
# request_headers = {
147+
# Accept = "application/json"
148+
# Authorization = "Bearer ${data.google_client_config.current.access_token}" }
149+
# depends_on = [
150+
# time_sleep.wait_to_recheck_workflow,
151+
# ]
152+
# }
153+
154+
# data "http" "retry_workflows_2" {
155+
# count = data.http.call_workflows_state.executions[0].state == "SUCCEEDED" || data.http.call_workflows_state.executions[0].state == "ACTIVE" ? 0 : 1
156+
# url = "https://workflowexecutions.googleapis.com/v1/projects/${module.project-services.project_id}/locations/${var.region}/workflows/${google_workflows_workflow.workflow.name}/executions"
157+
# method = "POST"
158+
# request_headers = {
159+
# Accept = "application/json"
160+
# Authorization = "Bearer ${data.google_client_config.current.access_token}" }
161+
# depends_on = [
162+
# data.http.call_workflows_state_2]
163+
# }
164+
165+
# Sleep for 120 seconds to allow the workflow to execute and finish setup
166+
resource "time_sleep" "complete_workflow" {
167+
count = data.http.call_workflows_state_1.executions[0].state == "SUCCEEDED" ? 0 : 1
168+
create_duration = "120s"
169+
depends_on = [
170+
data.http.retry_workflows_1,
171+
]
172+
}

0 commit comments

Comments
 (0)