【问题标题】:error on airflow webserver based on postgres基于postgres的气流网络服务器错误
【发布时间】:2020-04-30 08:46:56
【问题描述】:

基本上,我想构建 docker-airflow:

我有这样的 Dockerfile:

FROM puckel/docker-airflow:1.10.6
COPY ./airflow_home/airflow.cfg /usr/local/airflow/airflow.cfg
...

我有 docker-compose.yml 之类的:

version: "3.4"
services:
    postgres:
        image: "postgres:9.6"
        container_name: "postgres"
        environment:
            - POSTGRES_USER=airflow
            - POSTGRES_PASSWORD=airflow
            - POSTGRES_DB=airflow
        ports:
            - "5432:5432"
        volumes:
            - './data/postgres:/var/lib/postgresql/data'
    # comment initdb after you will have use it at first run
    # set the client and processed log types here
    initdb:
        build: .
        entrypoint: airflow initdb
        entrypoint:
            ['python3', '/usr/local/airflow/__init__.py', '-C', '$Client', '-T', '$Types']
        volumes:
            - './airflow_home/packages:/usr/local/airflow/packages'
        depends_on:
            - postgres

而且 requirements.txt 中没有其他气流库。

我在执行以下操作时总是遇到错误:

docker-compose up webserver

错误是:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "connection" does not exist
webserver_1  | LINE 2: FROM connection GROUP BY connection.conn_id

“xxx”也包括日志

我原本以为错误来自不同的版本。但我确保版本已被确认正确。我使用了来自相同版本的airflow.cfg,并使用Postgres 修改了sql_connection。 Postgres 中的数据库也已创建。有谁知道如何解决这个问题?

【问题讨论】:

  • 我不清楚你为什么需要 initdb 部分? puckel docker 将在启动时运行 initdb。此外,您没有在发布的 sn-p 中包含气流部分。 initdb 好像没有正常运行,查看启动气流的日志
  • 因为我需要为以下过程初始化一些参数。我以前考得很好。 postgresinitdb 都运行成功。我会尽快附上日志
  • 我会让气流图像运行 initdb 部分。气流的大多数参数都可以使用环境变量进行配置。
  • 感谢您的意见。也许我会试一试。但现在我认为问题不在 initdb 上。

标签: postgresql docker-compose airflow


【解决方案1】:

我找到了原因。 因为我在 initdb 部分使用了两个入口点。它将覆盖 docker 内的原始初始化脚本。当我删除入口点时:

['python3', '/usr/local/airflow/__init__.py', '-C', '$Client', '-T', '$Types']

现在可以了。

【讨论】:

  • 如果你想在 docker 中执行命令,我会推荐。最好在 Dockerfile 中使用 CMD。修复参数带来的bug,节省了大量时间
猜你喜欢
  • 1970-01-01
  • 2022-07-05
  • 2021-03-06
  • 2018-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-12
  • 1970-01-01
相关资源
最近更新 更多