简体   繁体   English

API 调用创建 GCP 和创建之间的延迟

[英]Delay between API call to create GCP and creation

I'm trying to write a script that will create a new google cloud project, then provision firebase resources to it, all using the Node SDK.我正在尝试编写一个脚本来创建一个新的谷歌云项目,然后为其提供 firebase 资源,所有这些都使用节点 SDK。

The first step is calling google.cloudresourcemanager("v1").projects.create, and I use an organization-level service account for that with the proper permissions which returns the proper Operation object on success.第一步是调用 google.cloudresourcemanager("v1").projects.create,我使用具有适当权限的组织级服务帐户,成功返回适当的操作 object。

The issue is that after this call, there's often a delay of up to several hours before a call to google.cloudresourcemanager("v1").projects.get or google.firebase({version: "v1beta1"}).projects.addFirebase works, and if you check in the console the project isn't there.问题是,在此调用之后,调用 google.cloudresourcemanager("v1").projects.get 或 google.firebase({version: "v1beta1"}).projects.addFirebase 通常会延迟长达几个小时有效,如果您在控制台中签入,则项目不存在。 The issue is not with permissions (authorization/authentication) as when I manually verify that a project exists then call those two functions, they work as expected.问题不在于权限(授权/身份验证),因为当我手动验证项目是否存在然后调用这两个函数时,它们按预期工作。

Has anybody else experienced something like this?有没有其他人经历过这样的事情?

thanks!谢谢!

On the Official API Documentation it is mentioned this:官方 API 文档中提到了这一点:

Request that a new Project be created.请求创建一个新项目。 The result is an Operation which can be used to track the creation process.结果是一个可用于跟踪创建过程的操作。 This process usually takes a few seconds, but can sometimes take much longer .此过程通常需要几秒钟,但有时可能需要更长的时间 The tracking Operation is automatically deleted after a few hours, so there is no need to call operations.delete.跟踪Operation会在几个小时后自动删除,因此无需调用operations.delete。

This means that this method works in an asynchronous way.这意味着此方法以异步方式工作。 As the response can be used to track the creation of the project, but it hasn't been fully created when the API answers.由于响应可用于跟踪项目的创建,但在 API 回答时尚未完全创建。

Also it Mentiones that it can take long time.它还提到它可能需要很长时间。

As this is how the API works all the SDKs including the NodeJS one will share this behavior.因为这就是 API 的工作方式,所以包括 NodeJS 在内的所有 SDK 都将共享此行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM