Docker 为什么气流试图在ubuntu服务器上运行sudo任务,但失败了?
我最近在Ubuntu服务器上部署了Airflow,使用官方Airflow docker映像和docker compose文件作为基础 一开始,我的本地windows 10计算机和服务器上的一切都运行良好。 但由于几天之后,我的所有DAG/任务都在服务器上失败,日志中出现以下错误消息:Docker 为什么气流试图在ubuntu服务器上运行sudo任务,但失败了?,docker,ubuntu,unix,airflow,Docker,Ubuntu,Unix,Airflow,我最近在Ubuntu服务器上部署了Airflow,使用官方Airflow docker映像和docker compose文件作为基础 一开始,我的本地windows 10计算机和服务器上的一切都运行良好。 但由于几天之后,我的所有DAG/任务都在服务器上失败,日志中出现以下错误消息: [2021-05-05 09:24:51,274] {taskinstance.py:1063} INFO - Executing <Task(PythonOperator): extract_eve
[2021-05-05 09:24:51,274] {taskinstance.py:1063} INFO - Executing <Task(PythonOperator): extract_events> on 2021-05-05T08:00:00+00:00
[2021-05-05 09:24:51,274] {base_task_runner.py:133} INFO - Running on host: 206851aec3f2
[2021-05-05 09:24:51,274] {base_task_runner.py:134} INFO - Running: ['sudo', '-E', '-H', '-u', 'airflow', 'airflow', 'tasks', 'run', 'events_pipeline', 'extract_events', '2021-05-05T08:00:00+00:00', '--job-id', '3', '--pool', 'default_pool', '--raw', '--subdir', 'DAGS_FOLDER/sro/events_dag.py', '--cfg-path', '/tmp/tmpvzvt2zyj', '--error-file', '/tmp/tmp8dbgrtf6']
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events We trust you have received the usual lecture from the local System
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events Administrator. It usually boils down to these three things:
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events #1) Respect the privacy of others.
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events #2) Think before you type.
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events #3) With great power comes great responsibility.
[2021-05-05 09:24:51,287] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events
[2021-05-05 09:24:51,288] {base_task_runner.py:118} INFO - Job 3: Subtask extract_events sudo: no tty present and no askpass program specified
[2021-05-05 09:24:51,288] {local_task_job.py:146} INFO - Task exited with return code 1
和docker compose文件:
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Basic Airflow cluster configuration for CeleryExecutor with Redis and PostgreSQL.
#
# WARNING: This configuration is for local development. Do not use it in a production deployment.
#
# This configuration supports basic configuration using environment variables or an .env file
# The following variables are supported:
#
# AIRFLOW_IMAGE_NAME - Docker image name used to run Airflow.
# Default: apache/airflow:master-python3.8
# AIRFLOW_UID - User ID in Airflow containers
# Default: 50000
# AIRFLOW_GID - Group ID in Airflow containers
# Default: 50000
# _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account.
# Default: airflow
# _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account.
# Default: airflow
#
# Feel free to modify this file to suit your needs.
---
version: '3'
x-airflow-common:
&airflow-common
# This is the image created by running the docker file.
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow-odbc:2.0.1}
environment:
&airflow-common-env
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CORE__FERNET_KEY: ''
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW__CORE__LOAD_EXAMPLES: 'false'
volumes:
- ./config/airflow.cfg:/opt/airflow/airflow.cfg
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
user: "${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}"
depends_on:
postgres:
condition: service_healthy
services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- postgres-db-volume:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 5s
retries: 5
restart: always
airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- 8080:8080
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
interval: 10s
timeout: 10s
retries: 5
restart: always
airflow-scheduler:
<<: *airflow-common
command: scheduler
restart: always
airflow-init:
<<: *airflow-common
command: version
environment:
<<: *airflow-common-env
_AIRFLOW_DB_UPGRADE: 'true'
_AIRFLOW_WWW_USER_CREATE: 'true'
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
volumes:
postgres-db-volume:
<代码>授权给Apache软件基金会(ASF)
#一个或多个参与者许可协议。见通知文件
#与此工作一起分发以获取更多信息
#关于版权所有权。ASF许可此文件
#根据Apache许可证,版本2.0(
#“许可证”);除非符合规定,否则您不得使用此文件
#带着执照。您可以通过以下方式获得许可证副本:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#除非适用法律要求或书面同意,
#根据许可证分发的软件在
#“按原样”的基础上,没有任何
#种类,无论是明示的还是暗示的。请参阅许可证以获取详细信息
#管理权限和限制的特定语言
#根据许可证。
#
#带Redis和PostgreSQL的CeleryExecutor的基本气流群集配置。
#
#警告:此配置用于本地开发。不要在生产部署中使用它。
#
#此配置支持使用环境变量或.env文件进行基本配置
#支持以下变量:
#
#气流\u图像\u名称-用于运行气流的Docker图像名称。
#默认值:apache/airflow:master-python3.8
#气流\u UID-气流容器中的用户ID
#默认值:50000
#气流_GID-气流容器中的组ID
#默认值:50000
#\u\u WWW\u USER\u USERNAME-管理员帐户的用户名。
#默认值:气流
#\u\u WWW\u USER\u PASSWORD-管理员帐户的密码。
#默认值:气流
#
#请随意修改此文件以满足您的需要。
---
版本:“3”
x-通用:
&普通气流
#这是通过运行docker文件创建的图像。
图像:${AIRFLOW\u图像\u名称:-apache/AIRFLOW odbc:2.0.1}
环境:
&气流共同环境
气流核心执行器:本地执行器
气流核心炼金术控制:postgresql+psycopg2://气流:airflow@postgres/气流
气流\uuuuu芯\uuuuuu FERNET\u键:“”
气流\uuuuu核心\uuuuu DAG \uu在\u创建时暂停\uu:'真'
气流\uuuuu芯\uuuuu负载\u示例:“错误”
卷数:
-./config/afflow.cfg:/opt/afflow/afflow.cfg
-/DAG:/opt/afflow/DAG
-/日志:/opt/气流/日志
-/插件:/opt/气流/插件
用户:${AIRFLOW\u UID:-50000}:${AIRFLOW\u GID:-50000}
取决于:
博士后:
状况:服务健康
服务:
博士后:
图片:博士后:13
环境:
POSTGRES_用户:气流
POSTGRES_密码:0
POSTGRES_DB:气流
卷数:
-postgres db卷:/var/lib/postgresql/data
健康检查:
测试:[“CMD”、“pg_isready”、“-U”、“气流”]
间隔:5秒
重试次数:5次
重新启动:始终
网络服务器:
我发现问题是由以下条目引起的: 默认模拟=气流 在我的气流配置文件中。移除后,问题消失了
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Basic Airflow cluster configuration for CeleryExecutor with Redis and PostgreSQL.
#
# WARNING: This configuration is for local development. Do not use it in a production deployment.
#
# This configuration supports basic configuration using environment variables or an .env file
# The following variables are supported:
#
# AIRFLOW_IMAGE_NAME - Docker image name used to run Airflow.
# Default: apache/airflow:master-python3.8
# AIRFLOW_UID - User ID in Airflow containers
# Default: 50000
# AIRFLOW_GID - Group ID in Airflow containers
# Default: 50000
# _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account.
# Default: airflow
# _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account.
# Default: airflow
#
# Feel free to modify this file to suit your needs.
---
version: '3'
x-airflow-common:
&airflow-common
# This is the image created by running the docker file.
image: ${AIRFLOW_IMAGE_NAME:-apache/airflow-odbc:2.0.1}
environment:
&airflow-common-env
AIRFLOW__CORE__EXECUTOR: LocalExecutor
AIRFLOW__CORE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
AIRFLOW__CORE__FERNET_KEY: ''
AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
AIRFLOW__CORE__LOAD_EXAMPLES: 'false'
volumes:
- ./config/airflow.cfg:/opt/airflow/airflow.cfg
- ./dags:/opt/airflow/dags
- ./logs:/opt/airflow/logs
- ./plugins:/opt/airflow/plugins
user: "${AIRFLOW_UID:-50000}:${AIRFLOW_GID:-50000}"
depends_on:
postgres:
condition: service_healthy
services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
volumes:
- postgres-db-volume:/var/lib/postgresql/data
healthcheck:
test: ["CMD", "pg_isready", "-U", "airflow"]
interval: 5s
retries: 5
restart: always
airflow-webserver:
<<: *airflow-common
command: webserver
ports:
- 8080:8080
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
interval: 10s
timeout: 10s
retries: 5
restart: always
airflow-scheduler:
<<: *airflow-common
command: scheduler
restart: always
airflow-init:
<<: *airflow-common
command: version
environment:
<<: *airflow-common-env
_AIRFLOW_DB_UPGRADE: 'true'
_AIRFLOW_WWW_USER_CREATE: 'true'
_AIRFLOW_WWW_USER_USERNAME: ${_AIRFLOW_WWW_USER_USERNAME:-airflow}
_AIRFLOW_WWW_USER_PASSWORD: ${_AIRFLOW_WWW_USER_PASSWORD:-airflow}
volumes:
postgres-db-volume: