google-cloud-platform - 部署管理器 : Operation failed because another operation was already in progress

标签 google-cloud-platform google-cloud-sql google-deployment-manager

我想在一个cloudsql实例中创建两个数据库。 但如果按照下面的方式写的话就会出错。

resources:
- name: test-instance
  type: sqladmin.v1beta4.instance
  properties:
    region: us-central
    backendType: SECOND_GEN
    instanceType: CLOUD_SQL_INSTANCE
    settings:
      tier: db-f1-micro
- name: test_db1
  type: sqladmin.v1beta4.database
  properties:
    instance: $(ref.test-instance.name)
    charset: utf8mb4
    collation: utf8mb4_general_ci
- name: test_db2
  type: sqladmin.v1beta4.database
  properties
    instance: $(ref.test-instance.name)
    charset: utf8mb4
    collation: utf8mb4_general_ci

输出:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation 
[operation-********]
- code: RESOURCE_ERROR
  location: /deployments/sample-deploy/resources/test_db2
   message:
'{"ResourceType":"sqladmin.v1beta4.database","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"errors":[{"domain":"global","message":"Operation
    failed because another operation was already in progress.","reason":"operationInProgress"}],"message":"Operation
    failed because another operation was already in progress.","statusMessage":"Forbidden","requestPath":"https://www.googleapis.com/sql/v1beta4/projects/****/instances/test-instance/databases","httpMethod":"POST"}}'

请告诉我如何解决该错误。

最佳答案

错误“ResourceErrorCode”是源自 CloudSQL API 的错误。 。

这里的问题是部署管理器将尝试并行运行所有资源修改(除非您指定资源之间的依赖关系)。部署管理器是一种声明性配置,它将并行运行部署,无论它们是否相互独立。

在这种特定情况下,CloudSQL 无法同时创建两个数据库。这就是您看到错误消息的原因:操作失败,因为另一个操作已在进行中

由于固有的系统架构,在给定时间点只能有一个待处理操作。这是对 CloudSQL 数据库并发写入的限制。

要解决此问题,您必须按顺序而不是并行创建两个数据库。

有关如何操作的更多信息,您可以咨询the documentation在这个问题上。

关于google-cloud-platform - 部署管理器 : Operation failed because another operation was already in progress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50960937/

相关文章:

python - 谷歌云运行 : Calling from outside GCP

php - 无法在实例 google cloud sql 中分配 ipv4 地址

google-cloud-platform - 在 GCP Deployment Manager 配置中使用 Stackdriver 资源组的 ID

google-app-engine - Objectify 库可以在 GAE 之外使用吗?

javascript - Google Cloud Function 未处理的拒绝

python - 查询特定意图 Dialogflow apiv2

mysql - Google Cloud SQL 声称我的数据库比 MySQL-Workbench 大得多

python-3.x - Flask SQLalchemy 无法使用 Unix 套接字连接到 Google Cloud Postgresql 数据库

google-cloud-platform - 如何从 GUI 生成 Cloud Deployment Manager 配置 YAML?

google-cloud-platform - GCP 授予服务帐户使用 Deployment Manager 写入 GCS 存储桶的权限