Airflow KubernetesPodOperator 任务在达到执行超时之前因 SIGTERM 终止

问题描述 投票:0回答:1

我正在运行一个 Airflow DAG,它利用 KubernetesPodOperator 在 Kubernetes 集群中执行任务。但是,我遇到了一个问题,即我的几个任务在达到其定义的

execution_timeout
之前就被 SIGTERM 信号终止。

请注意,在更新 Airflow 之前,我不记得看到过此问题。老实说,我认为这不一定是 Airflow 版本的问题,而是我的 DAG 或 Kubernetes-Helm 中的配置错误

我的包裹

awswrangler==2.19.0
apache-airflow==2.7.1
apache-airflow-providers-cncf-kubernetes==7.5.1
apache-airflow-providers-amazon==8.6.0
boto3==1.28.39
gnupg==2.3.1
PyYAML==6.0.1

这是我在日志中看到的错误:

[2023-10-09, 13:52:40 UTC] {local_task_job_runner.py:115} ERROR - Received SIGTERM. Terminating subprocesses
...
[2023-10-09, 13:52:40 UTC] {taskinstance.py:1630} ERROR - Received SIGTERM. Terminating subprocesses.
...
[2023-10-09, 13:52:40 UTC] {taskinstance.py:1935} ERROR - Task failed with exception

在我的 DAG 中,我将每个任务的execution_timeout 设置为 24 小时:

execution_timeout=timedelta(hours=24)

但是,任务将在 11 小时左右或更早终止。

这是我的 DAG 的片段:

with DAG(
    ...
) as dag:
    my_process = KubernetesPodOperator(
        ...
        execution_timeout=timedelta(hours=24),
        container_resources=RESOURCES['medium']
        ...
        **pod_args
    )
    ...

从我的 config.py 中:

RESOURCES = {
    ...
    'medium': client.V1ResourceRequirements(
        requests={"cpu": "2000m", "memory": "2Gi"},
        limits={"cpu": "2000m", "memory": "2Gi"}
    ),
    ...
}

pod_args = {
    'namespace': "airflow",
    'service_account_name': "airflow",
    'image_pull_secrets': [k8s.V1LocalObjectReference("docker-registry")],
    'env_vars': {
        "EXECUTION_DATE": "{{ execution_date }}",
    },
    'in_cluster': True,
    'get_logs': True,
    'on_finish_action': 'delete_succeeded_pod',
}

我已确保资源得到适当分配,并且 Kubernetes 集群本身没有问题。

是否有人遇到过类似的问题,或者可以提供有关为什么任务可能在达到execution_timeout 之前收到SIGTERM 的见解?任何帮助或指导将不胜感激!

kubernetes airflow airflow-2.x sigterm
1个回答
0
投票

您能够解决这个问题吗?当我们的气流达到峰值负载时,我会间歇性地面临这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.