如何避免从同一模板启动多个数据流作业时出现"IN_USED_ADDRESSES"错误?



我创建了一个数据流模板,该模板允许我将数据从云存储中的CSV文件导入BigQuery。我使用Firebase的Cloud Function在每天的特定时间从这个模板创建作业。这是函数中的代码(去掉了一些不相关的部分(。

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。然而,我不知道如何以一种不会填满地址的方式开始工作。那么,我该如何避免这种情况呢?如果我不能,那么我应该使用什么方法?

我在这里的另一篇文章中回答了这个问题-需要更新哪些计算引擎配额才能运行具有50个工作线程的数据流(in_USE_ADDRESSES、CPUS、CPUS_ALL_REGIONS...(?。

如果有帮助,请告诉我。

这是GCP外部IP配额问题,最好的解决方案是,只要管道资源位于GCP网络内,就不要将任何公共IP用于数据流作业。在数据流作业中启用公共IP:

  1. 创建或更新子网络以允许Private google access。这是相当简单的使用控制台-VPC>网络>子网络>勾选启用私人谷歌访问

  2. 在Cloud Dataflow作业的参数中,指定--usePublicIps=false--network=[NETWORK]--subnetwork=[SUBNETWORK]

注意:-对于内部IP IN_USED错误,只需更改子网CIDR范围以容纳更多地址(如20.0.0.0/16(,即可获得接近60k的内部IP地址。

这样,你将永远不会超过你的内部IP范围

最新更新