【问题标题】:Dataflow with python flex template - launcher timeout带有 python flex 模板的数据流 - 启动器超时
【发布时间】:2021-02-25 00:51:43
【问题描述】:

我正在尝试使用 flex 模板运行我的 python 数据流作业。当我使用直接运行器(没有 flex 模板)运行时,作业在本地运行良好,但是当我尝试使用 flex 模板运行它时,作业卡在“排队”状态一段时间,然后超时失败。

这是我在 GCE 控制台中找到的一些日志:

INFO:apache_beam.runners.portability.stager:Executing command: ['/usr/local/bin/python', '-m', 'pip', 'download', '--dest', '/tmp/dataflow-requirements-cache', '-r', '/dataflow/template/requirements.txt', '--exists-action', 'i', '--no-binary', ':all:'

Shutting down the GCE instance, launcher-202011121540156428385273524285797, used for launching.

Timeout in polling result file: gs://my_bucket/staging/template_launches/2020-11-12_15_40_15-6428385273524285797/operation_result.
Possible causes are:
1. Your launch takes too long time to finish. Please check the logs on stackdriver.
2. Service my_service_account@developer.gserviceaccount.com may not have enough permissions to pull container image gcr.io/indigo-computer-272415/samples/dataflow/streaming-beam-py:latest or create new objects in gs://my_bucket/staging/template_launches/2020-11-12_15_40_15-6428385273524285797/operation_result.
3. Transient errors occurred, please try again.

对于 1,我看不到有用的 lo。对于 2,服务帐户是默认服务帐户,因此它应该具有所有权限。

如何进一步调试?

这是我的 Docker 文件:

FROM gcr.io/dataflow-templates-base/python3-template-launcher-base

ARG WORKDIR=/dataflow/template
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}

ADD localdeps localdeps
COPY requirements.txt .
COPY main.py .
COPY setup.py .
COPY bq_field_pb2.py .
COPY bq_table_pb2.py .
COPY core_pb2.py .

ENV FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE="${WORKDIR}/requirements.txt"
ENV FLEX_TEMPLATE_PYTHON_PY_FILE="${WORKDIR}/main.py"
ENV FLEX_TEMPLATE_PYTHON_SETUP_FILE="${WORKDIR}/setup.py"

RUN pip install -U  --no-cache-dir -r ./requirements.txt

我正在关注本指南 - https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates

【问题讨论】:

  • 在运行模板时,是否可以明确指定一个服务账户,该服务账户有权通过--parameters service_account_email="foo@bar.iam.gserviceaccount.com"访问桶
  • 它没有帮助。事实上,我能够在上面的文档中运行 github 示例项目而没有问题
  • 您链接到的指南没有提及 FLEX_TEMPLATE_PYTHON_SETUP_FILE (诚然,今天是您在上面发布消息两个多月后,这个 flex 模板内容目前似乎正在迅速变化)。您是否知道其他解释 FLEX_TEMPLATE_PYTHON_SETUP_FILE 的文档,因为我找不到任何文档。
  • 文档非常糟糕:/ 我想我在示例存储库中找到了它。这是github.com/GoogleCloudPlatform/python-docs-samples/issues/…字段的解释

标签: google-cloud-platform google-cloud-dataflow apache-beam data-pipeline


【解决方案1】:

可以在requirements.txt 文件中找到此问题的可能原因。如果您尝试在需求文件中安装 apache-beam,则 flex 模板将遇到您所描述的确切问题:作业在 Queued 状态下停留一段时间,最后以 Timeout in polling result 失败。

原因是,它们受到this 问题的影响。这只会影响弹性模板,作业在本地或使用标准模板正常运行。

解决办法是在Dockerfile中单独安装。

RUN pip install -U apache-beam==<your desired version>
RUN pip install -U -r ./requirements.txt

【讨论】:

【解决方案2】:

下载要求以加快启动 Dataflow 作业。

FROM gcr.io/dataflow-templates-base/python3-template-launcher-base

ARG WORKDIR=/dataflow/template
RUN mkdir -p ${WORKDIR}
WORKDIR ${WORKDIR}

COPY . .

ENV FLEX_TEMPLATE_PYTHON_PY_FILE="${WORKDIR}/main.py"
ENV FLEX_TEMPLATE_PYTHON_SETUP_FILE="${WORKDIR}/setup.py"
ENV FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE="${WORKDIR}/requirements.txt"

RUN apt-get update \
    # Upgrade pip and install the requirements.
    && pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir -r $FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE \
    # Download the requirements to speed up launching the Dataflow job.
    && pip download --no-cache-dir --dest /tmp/dataflow-requirements-cache -r $FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE


# Since we already downloaded all the dependencies, there's no need to rebuild everything.
ENV PIP_NO_DEPS=True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 2021-03-26
    • 2021-06-16
    • 1970-01-01
    • 2015-03-10
    • 2013-07-05
    • 1970-01-01
    相关资源
    最近更新 更多