feat(dags): Add Workday - XMatters integration DAG (ASP-4546) (#2005)

* First commit with the workday-xmatters DAG

* First commit with the workday-xmatters DAG

* Changed the jira_conn_id name

* Fixed ruff errors

* Fixed a ruff error

* Fixed black format

* Added  apache-airflow-providers-atlassian-jira to requirements

* Fixed requirements.txt

* Fixed pytest error

* Fixed top-level code

* Changed the task definition back to what it was before

* Reformated file

* Added new line

---------

Co-authored-by: Julio Cezar Moscon <jcmoscon@gmail.com>
This commit is contained in:
JCMOSCON1976 2024-05-31 11:49:28 -04:00 коммит произвёл GitHub
Родитель a726a86bba
Коммит f9d466c985
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 71 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,66 @@
from datetime import datetime
from airflow import DAG
from operators.gcp_container_operator import GKEPodOperator
from utils.tags import Tag
DOCS = """
### Workday/XMatters integration
Runs a script in docker image that syncs employee data
from Workday to XMatters.
It creates a Jira ticket if the task fails.
[docker-etl](https://github.com/mozilla/docker-etl/tree/main/jobs/eam-integrations)
This DAG requires the creation of an Airflow Jira connection.
#### Owner
jmoscon@mozilla.com
"""
def on_failure_callback(context):
from airflow.providers.atlassian.jira.notifications.jira import (
send_jira_notification,
)
exception = context.get("exception")
send_jira_notification(
jira_conn_id="eam_jira_connection_id",
description=f"Workday XMatters Integration \
Task 1 failed. Exception = {exception}",
summary="Airflow Task Issue Exception",
# use this link to find project id and issue type ids :
# https://mozilla-hub.atlassian.net/rest/api/latest/project/ASP
project_id=10051,
issue_type_id=10007,
labels=["airflow-task-failure"],
).notify(context)
default_args = {
"owner": "jmoscon@mozilla.com",
"emails": ["jmoscon@mozilla.com"],
"start_date": datetime(2024, 1, 1),
"retries": 0,
"on_failure_callback": [on_failure_callback],
}
tags = [Tag.ImpactTier.tier_2, Tag.ImpactTier.tier_3]
with DAG(
"eam-workday-xmatters-integration",
default_args=default_args,
doc_md=DOCS,
tags=tags,
schedule_interval="@daily",
) as dag:
workday_xmatters_dag = GKEPodOperator(
task_id="eam_workday_xmatters",
arguments=["python", "scripts/workday_xmatters.py", "--level", "info"],
image="gcr.io/moz-fx-data-airflow-prod-88e0/ \
eam-integrations_docker_etl:latest",
gcp_conn_id="google_cloud_airflow_gke",
)

Просмотреть файл

@ -24,3 +24,6 @@ gql
# Required for /app/dags/fivetran_acoustic.py, /app/dags/utils/acoustic/acoustic_client.py
xmltodict
# Required for /app/dags/empeam_workday_xmatters_integration.py
apache-airflow-providers-atlassian-jira

Просмотреть файл

@ -16,6 +16,7 @@ annotated-types==0.6.0
anyio==4.3.0
apache-airflow==2.8.2
apache-airflow-providers-amazon==8.18.0
apache-airflow-providers-atlassian-jira==2.5.1
apache-airflow-providers-celery==3.6.0
apache-airflow-providers-cncf-kubernetes==8.0.0
apache-airflow-providers-common-io==1.3.0
@ -32,6 +33,7 @@ apispec==6.4.0
argcomplete==3.2.2
asgiref==3.7.2
asn1crypto==1.5.1
atlassian-python-api==3.41.10
attrs==23.2.0
authlib==1.3.0
avro==1.11.3