我创建了一个Dataflow模板,它允许我将数据从Cloud中的CSV文件导入到BigQuery中。我每天都使用云函数Firebase从这个模板创建工作。这是函数中的代码(删除了一些不相关的部分)。
const filePath = object.name?.replace(".csv", "");
// Exit function if file changes are in temporary or staging folder
if (
filePath?.includes("staging") ||
filePath?.includes("temp") ||
filePath?.includes("templates")
)
return;
const dataflow = google.dataflow("v1b3");
const auth = await google.auth.getClient({
scopes: ["https://www.googleapis.com/auth/cloud-platform"],
});
let request = {
auth,
projectId: process.env.GCLOUD_PROJECT,
location: "asia-east1",
gcsPath: "gs://my_project_bucket/templates/csv_to_bq",
requestBody: {
jobName: `csv-to-bq-${filePath?.replace(/\//g, "-")}`,
environment: {
tempLocation: "gs://my_project_bucket/temp",
},
parameters: {
input: `gs://my_project_bucket/${object.name}`,
output: biqQueryOutput,
},
},
};
return dataflow.projects.locations.templates.launch(request);
每次在云存储中写入任何文件时,都会触发此函数。我正在使用传感器,所以至少我必须在15分钟内导入89个不同的数据,即不同的CSV文件。
如果只有4个工作同时工作,整个过程可以正常工作。但是,当函数试图创建第五个作业时,API返回了许多不同类型的错误。
错误1(不准确,因为不知何故我再也找不到错误了):
Error Response: [400] The following quotas were exceeded: IN_USE_ADDRESSES
错误2:
Dataflow quota error for jobs-per-project quota. Project *** is running 25 jobs.
Please check the quota usage via GCP Console.
If it exceeds the limit, please wait for a workflow to finish or contact Google Cloud Support to request an increase in quota.
If it does not, contact Google Cloud Support.
错误3:
Quota exceeded for quota metric 'Job template requests' and limit 'Job template requests per minute per user' of service 'dataflow.googleapis.com' for consumer 'project_number:****'.
我知道我可以腾出开始的作业,以避免错误2和3。然而,我不知道如何以一种不会填满地址的方式开始作业。那我该怎么避免呢?如果我不能,那我应该用什么方法呢?
发布于 2020-04-16 15:58:23
我在这里的另一篇文章中回答了这个问题-- Which Compute Engine quotas need to be updated to run Dataflow with 50 workers (IN_USE_ADDRESSES, CPUS, CPUS_ALL_REGIONS ..)?。
如果这有帮助的话请告诉我。
发布于 2020-04-22 14:26:58
这是一个GCP外部IP配额问题,最好的解决方案是,只要您的管道资源停留在GCP网络中,就不为数据流作业使用任何公共IP。要在数据流作业中启用公共IP:
Private google access
。这是相当简单的使用控制台- VPC >网络>子网络>勾选启用私有google access --usePublicIps=false
和--network=[NETWORK]
或--network=[NETWORK]
注意:对于内部IP IN_USED错误,只需更改您的子网CIDR范围,以适应更多的地址,例如20.0.0.0/16
将给您提供接近60k的内部IP地址。
这样,您将永远不会超过您的内部IP范围。
https://stackoverflow.com/questions/61253500
复制相似问题