google-cloud-platform - 无服务器 Dataproc 错误 - 需要批处理 ID

标签 google-cloud-platform google-cloud-dataproc google-cloud-dataproc-serverless

尝试使用 Rest API 使用 Serverless Dataproc 提交 Spark 作业时 https://cloud.google.com/dataproc-serverless/docs/quickstarts/spark-batch#dataproc_serverless_create_batch_workload-drest

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://dataproc.googleapis.com/v1/projects/project-id/locations/region/batches"

我收到此错误响应

{
  "error": {
    "code": 400,
    "message": "Batch ID is required",
    "status": "INVALID_ARGUMENT"
  }
}

我在这里缺少什么?

最佳答案

我使用 gcloud --log-http 进行了测试:

$ gcloud dataproc batches submit spark --log-http \
    --jars=file:///usr/lib/spark/examples/jars/spark-examples.jar \
    --class=org.apache.spark.examples.SparkPi \
    -- 1000
...
==== request start ====
uri: https://dataproc.googleapis.com/v1/projects/my-project/locations/us-west1/batches?alt=json&batchId=21dd24ca279a4603926d4e59d65bfaf9&requestId=21dd24ca279a4603926d4e59d65bfaf9
method: POST
...

请注意网址中的 batchId=21dd24ca279a4603926d4e59d65bfaf9

我还测试了使用 --batch 手动设置 ID:

$ gcloud dataproc batches submit spark --log-http  \
  --batch=foobar \
  --jars=file:///usr/lib/spark/examples/jars/spark-examples.jar \
  --class=org.apache.spark.examples.SparkPi \
  -- 1000

...
==== request start ====
uri: https://dataproc.googleapis.com/v1/projects/my-project/locations/us-west1/batches?alt=json&batchId=foobar&requestId=c7b5a753cac4483da21b1ba1c6c2a2d1
method: POST
...

似乎 REST API 需要在 URL 中添加 batchId 参数,但使用 gcloud 时它会自动生成一个参数。

关于google-cloud-platform - 无服务器 Dataproc 错误 - 需要批处理 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71311179/

相关文章:

kubernetes - Kubernetes Engine和Container Engine有什么区别?为什么后者没有出现在我的仪表板上?

google-compute-engine - Google Compute Engine上所有新规则的防火墙规则默认范围值

apache-spark - 使用 spark-shell 时的 Guava 版本

java - 谷歌云数据处理中谷歌 JDBC 驱动程序的 ClassNotFoundException

apache-spark - 如何重命名在 Dataproc Serverless 上运行的 Spark 中的 GCS 文件?

python - 部署 Python 灵活应用程序引擎,无需入口点,只需 cron 作业

firebase - 无法设置 Cloud Firebase 每日支出限额

google-cloud-platform - 在不超过配额的情况下创建集群

google-cloud-platform - Dataproc Serverless - 如何设置 javax.net.ssl.trustStore 属性以修复 java.security.cert.CertPathValidatorException