Deployment Manager:操作失败,因为另一项操作已在进行中

时间:2018-06-21 05:25:45

标签: 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"}}'

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

1 个答案:

答案 0 :(得分:2)

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

这里的问题是Deployment Manager将尝试并行运行所有资源修改(除非您指定资源之间的依赖关系)。 Deployment Manager是声明性配置,无论它们彼此独立与否,它将并行运行部署。

在这种特定情况下,CloudSQL无法同时创建两个数据库。这就是为什么您看到错误消息:Operation failed because another operation was already in progress

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

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

有关如何执行此操作的更多信息,您可以在此问题上咨询the documentation