Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dags/bc_obps_reset_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

RESET_DAG_DOC = """
DAG to reset the data in the BCIERS database to a freshly deployed state.

- **cycle_backend**: Whether to restart the backend deployment once the database has been wiped
"""


Expand All @@ -32,7 +34,7 @@
doc_md=RESET_DAG_DOC,
tags=['bciers'],
)
def reset_data():
def reset_data(cycle_backend: bool = True):

@task
def reset_attachment_storage_task():
Expand All @@ -42,6 +44,10 @@ def reset_attachment_storage_task():
def reset_data_task():
trigger_k8s_cronjob("reset-database", BCIERS_NAMESPACE)

@task.short_circuit
def should_cycle_backend(**context):
return context["params"]["cycle_backend"]

cycle_backend_pod_task = KubernetesJobOperator(
task_id="cycle-backend-pod",
name="cycle-backend-pod",
Expand All @@ -59,7 +65,12 @@ def reset_data_task():
trigger_dag_id=WAIT_FOR_BACKEND_ROLLOUT_DAG_NAME,
)

([reset_attachment_storage_task(), reset_data_task()] >> cycle_backend_pod_task >> trigger_wait_for_backend_rollout)
(
[reset_attachment_storage_task(), reset_data_task()]
>> should_cycle_backend()
>> cycle_backend_pod_task
>> trigger_wait_for_backend_rollout
)


ROLLOUT_DAG_DOC = """
Expand Down
Loading