2019-12-26 21:26:46 +03:00
|
|
|
from airflow import DAG
|
|
|
|
from datetime import timedelta, datetime
|
|
|
|
from operators.gcp_container_operator import GKEPodOperator
|
2022-01-06 21:13:55 +03:00
|
|
|
from utils.tags import Tag
|
2019-12-26 21:26:46 +03:00
|
|
|
|
2020-10-28 23:51:15 +03:00
|
|
|
docs = """
|
|
|
|
### Clean GKE Pods
|
|
|
|
|
2021-08-30 20:31:29 +03:00
|
|
|
Failures can be ignored during Airflow Triage. This job is idempotent.
|
|
|
|
|
2020-10-28 23:51:15 +03:00
|
|
|
Built from cloudops-infra repo, projects/airflow/pod-clean
|
|
|
|
|
|
|
|
#### Purpose
|
|
|
|
|
|
|
|
This DAG executes a GKEPodOperator to clean out old completed pods
|
|
|
|
on the shared derived-datasets gke cluster. We need to do this periodically
|
|
|
|
because GCP has a 1500 object limit quota.
|
|
|
|
|
|
|
|
#### Owner
|
|
|
|
|
|
|
|
hwoo@mozilla.com
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2019-12-26 21:26:46 +03:00
|
|
|
default_args = {
|
|
|
|
'owner': 'hwoo@mozilla.com',
|
|
|
|
'depends_on_past': False,
|
|
|
|
'start_date': datetime(2019, 12, 26),
|
|
|
|
'email_on_failure': True,
|
|
|
|
'email_on_retry': True,
|
|
|
|
'retries': 2,
|
|
|
|
'retry_delay': timedelta(minutes=30),
|
|
|
|
}
|
|
|
|
|
2022-01-06 21:13:55 +03:00
|
|
|
tags = [Tag.ImpactTier.tier_3]
|
|
|
|
|
|
|
|
dag = DAG("clean-gke-pods", default_args=default_args, schedule_interval="@daily", doc_md = docs, tags=tags,)
|
2019-12-26 21:26:46 +03:00
|
|
|
|
2022-06-28 20:56:03 +03:00
|
|
|
docker_image='us-west1-docker.pkg.dev/moz-fx-data-airflow-prod-88e0/data-science-artifacts/gke-pod-clean:1.3'
|
2020-01-16 10:08:43 +03:00
|
|
|
gke_cluster_name='bq-load-gke-1'
|
|
|
|
gke_location='us-central1-a'
|
|
|
|
|
2019-12-26 21:26:46 +03:00
|
|
|
docker_args = [
|
|
|
|
'--project', 'moz-fx-data-derived-datasets',
|
|
|
|
'--gke-cluster', gke_cluster_name,
|
|
|
|
'--region', gke_location,
|
2021-02-04 21:23:02 +03:00
|
|
|
'--retention-days', '4'
|
2019-12-26 21:26:46 +03:00
|
|
|
]
|
|
|
|
|
2020-01-10 06:28:02 +03:00
|
|
|
clean_gke_pods = GKEPodOperator(
|
|
|
|
task_id="clean-gke-pods",
|
|
|
|
name='clean-gke-pods',
|
2019-12-26 21:26:46 +03:00
|
|
|
image=docker_image,
|
|
|
|
arguments=docker_args,
|
|
|
|
dag=dag)
|