通过Airflow创建的Kubernetes容器保持运行状态

时间:2019-01-27 13:07:39

标签: kubernetes google-cloud-platform airflow

我已经在Kubernetes集群中设置了Airflow。要运行任务,我正在使用KubernetesPodOperator

当我运行任务并查看kubectl get pods时,我看到Pod已正确创建并且也已完成。但是,当我查看Airflow时,我发现状态没有更新,并且它仍处于运行状态。

[2019-01-27 12:43:56,580] {models.py:1595} INFO - Executing <Task(KubernetesPodOperator): xxx> on 2019-01-20T00:00:00+00:00
[2019-01-27 12:43:56,581] {base_task_runner.py:118} INFO - Running: ['bash', '-c', 'airflow run xxx xxx 2019-01-20T00:00:00+00:00 --job_id 15 --raw -sd DAGS_FOLDER/xxx.py --cfg_path /tmp/tmpxx39wldz']
[2019-01-27 12:45:21,603] {models.py:1355} INFO - Dependencies not met for <TaskInstance: xxx.xxx 2019-01-20T00:00:00+00:00 [running]>, dependency 'Task Instance Not Already Running' FAILED: Task is already running, it started on 2019-01-27 12:43:56.565328+00:00.
[2019-01-27 12:45:21,639] {models.py:1355} INFO - Dependencies not met for <TaskInstance: xxx.xxx 2019-01-20T00:00:00+00:00 [running]>, dependency 'Task Instance State' FAILED: Task is in the 'running' state which is not a valid state for execution. The task must be cleared in order to be run.
[2019-01-27 12:45:21,641] {logging_mixin.py:95} INFO - [2019-01-27 12:45:21,641] {jobs.py:2614} INFO - Task is not able to be run

我应该采取什么具体措施将吊舱的状态恢复为Airflow? KubernetesPodOperator的定义如下:

do_something = KubernetesPodOperator(
    task_id='xxx',
    image='gcr.io/project/image',
    namespace='default',
    name='xxx',
    arguments=['dummy'],
    xcom_push=True,
    in_cluster=True,
    image_pull_policy='Always',
    trigger_rule='dummy',
    dag=dag,
)

编辑::基本容器似乎已完成,但是airflow-xcom-sidecar仍在运行。我有什么具体措施可以制止那个?

1 个答案:

答案 0 :(得分:0)

很难不说出您的设置就说清楚,但是好像吊舱已经完成,它正试图xcom推入您的主气流,并且无法连接。我将检查airflow-xcom-sidecar的日志。像这样:

$ kubectl logs <airflow-job-pod> -c airflow-xcom-sidecar

您还可以尝试将KubernetesOperatorxcom_push=False一起运行:

do_something = KubernetesPodOperator(
    task_id='xxx',
    image='gcr.io/project/image',
    namespace='default',
    name='xxx',
    arguments=['dummy'],
    xcom_push=False,
    in_cluster=True,
    image_pull_policy='Always',
    trigger_rule='dummy',
    dag=dag,
)