Skip to content

Commit 3eae48b

Browse files
chore: add cycle_backend option to reset_data DAG
1 parent ec1a542 commit 3eae48b

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

dags/bc_obps_reset_data.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
RESET_DAG_DOC = """
2222
DAG to reset the data in the BCIERS database to a freshly deployed state.
23+
24+
- **cycle_backend**: Whether to restart the backend deployment once the database has been wiped
2325
"""
2426

2527

@@ -32,7 +34,7 @@
3234
doc_md=RESET_DAG_DOC,
3335
tags=['bciers'],
3436
)
35-
def reset_data():
37+
def reset_data(cycle_backend: bool = True):
3638

3739
@task
3840
def reset_attachment_storage_task():
@@ -42,6 +44,10 @@ def reset_attachment_storage_task():
4244
def reset_data_task():
4345
trigger_k8s_cronjob("reset-database", BCIERS_NAMESPACE)
4446

47+
@task.short_circuit
48+
def should_cycle_backend(**context):
49+
return context["params"]["cycle_backend"]
50+
4551
cycle_backend_pod_task = KubernetesJobOperator(
4652
task_id="cycle-backend-pod",
4753
name="cycle-backend-pod",
@@ -59,7 +65,12 @@ def reset_data_task():
5965
trigger_dag_id=WAIT_FOR_BACKEND_ROLLOUT_DAG_NAME,
6066
)
6167

62-
([reset_attachment_storage_task(), reset_data_task()] >> cycle_backend_pod_task >> trigger_wait_for_backend_rollout)
68+
(
69+
[reset_attachment_storage_task(), reset_data_task()]
70+
>> should_cycle_backend()
71+
>> cycle_backend_pod_task
72+
>> trigger_wait_for_backend_rollout
73+
)
6374

6475

6576
ROLLOUT_DAG_DOC = """

0 commit comments

Comments
 (0)