gcp dataflow templates, ERROR: (gcloud.beta.dataflow.jobs.run) INVALID_ARGUMENT: There is no support for job type with environment version

gcp dataflow templates, ERROR: (gcloud.beta.dataflow.jobs.run) INVALID_ARGUMENT: There is no support for job type with environment version

完全错误

错误:(gcloud.beta.dataflow.jobs.run)INVALID_ARGUMENT:(4361fe83f99d0cfe):环境版本不支持作业类型。请尝试将 SDK 升级到最新版本。您可以在 https://cloud.google.com/dataflow/docs/guides/installing-beam-sdk. If that doesn't work, please contact the Cloud Dataflow team for assistance at https://cloud.google.com/dataflow/support.

找到有关安装最新 SDK 的说明

暂存命令

mvn compile exec:java  -Dexec.mainClass=com.jobs.wordcount.TextToPubsub  -Dexec.args="--runner=DataflowRunner \
          --project=my_project \
          --stagingLocation=gs://bucket_name/tmp/staging \
          --templateLocation=gs://dataflow-templates/latest/Stream_GCS_Text_to_Cloud_PubSub_metadata"

运行命令

gcloud dataflow jobs run template_test \
--gcs-location gs://dataflow-templates/latest/Stream_GCS_Text_to_Cloud_PubSub_metadata \
--staging-location=gs:/my_bucket/tmp/staging \
--parameters \
inputFilePattern=gs://bucket_nam/input/*.json,\
outputTopic=projects/my_project/topics/testTopic

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>word_count_cicd_test</groupId>
    <artifactId>word_count_cicd_test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
     <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-core</artifactId>
        <version>[2.20.0, 2.99)</version>
    </dependency>

    <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-sdks-java-io-google-cloud-platform</artifactId>
        <version>2.20.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.beam</groupId>
        <artifactId>beam-runners-google-cloud-dataflow-java</artifactId>
        <version>[2.20.0, 2.99)</version>
    </dependency>
 </dependencies>

java代码和元数据模板由google

提供

https://cloud.google.com/dataflow/docs/guides/templates/provided-streaming#gcstexttocloudpubsubstream

gcloud 版本

bash-3.2$ gcloud version
    Google Cloud SDK 278.0.0
    beta 2019.05.17
    bq 2.0.52
    core 2020.01.24
    gsutil 4.47

我在控制台中启动时遇到同样的错误。我认为这可能与此功能处于测试阶段有关。

gs://dataflow-templates/latest/Stream_GCS_Text_to_Cloud_PubSub_metadata 不是有效模板。它是模板的元数据文件,gs://dataflow-templates/latest/Stream_GCS_Text_to_Cloud_PubSub.

如果你想要运行Google提供的模板版本,你可以在你的gcloud命令中设置--gcs_location=gs://dataflow-templates/latest/Stream_GCS_Text_to_Cloud_PubSub

如果您想创建自己的模板,则必须在暂存命令的 templateLocation 中使用自己的 GCS 存储桶。