如何获取导出云数据存储的结果详情?

How to get result detail of export Cloud Datastore?

我有一个将用户数据存储在 GCP 数据存储区中的应用程序。 我做了一个 cron 作业,计划使用给定的说明导出 Datastore 中的数据 here

现在,我想得到这个作业失败时的结果和完成时间。 (不是 cron,而是 cron 移动的作业)

如何获取导出云数据存储的结果详情?

计划的数据存储导出(和导入)可以是长时间的 运行 操作,因此它们支持 asynchronous execution and progress monitoring

基本上,当您启动操作时,您会得到一个操作 ID:

For example, when you start an export, the Cloud Datastore service creates a long-running operation to track the export status. Here's the output from the start of an export:

{
  "name": "projects/[YOUR_PROJECT_ID]/operations/ASAyMDAwOTEzBxp0bHVhZmVkBxJsYXJ0bmVjc3Utc2Jvai1uaW1kYRQKKhI",
  "metadata": {
    "@type": "type.googleapis.com/google.datastore.admin.v1.ExportEntitiesMetadata",
    "common": {
      "startTime": "2017-05-25T23:54:39.583780Z",
      "operationType": "EXPORT_ENTITIES"
    },
    "progressEntities": {},
    "progressBytes": {},
    "entityFilter": {
      "namespaceIds": [
        ""
      ]
    },
    "outputUrlPrefix": "gs://[YOUR_BUCKET_NAME]"
  }
}

The value of the name field is the ID of a long-running operation.

然后您可以使用带有projects.operations.get in the operation Admin API的操作ID来获取其完成时间和结果URL:

This example output shows a recently completed export operation. Operations are accessible for a few days after completion:

{
  "operations": [
    {
      "name": "projects/[YOUR_PROJECT_ID]/operations/ASAyMDAwOTEzBxp0bHVhZmVkBxJsYXJ0bmVjc3Utc2Jvai1uaW1kYRQKKhI",
      "metadata": {
        "@type": "type.googleapis.com/google.datastore.admin.v1.ExportEntitiesMetadata",
        "common": {
          "startTime": "2017-12-05T23:01:39.583780Z",
          "endTime": "2017-12-05T23:54:58.474750Z",
          "operationType": "EXPORT_ENTITIES"
        },
        "progressEntities": {
          "workCompleted": "21933027",
          "workEstimated": "21898182"
        },
        "progressBytes": {
          "workCompleted": "12421451292",
          "workEstimated": "9759724245"
        },
        "entityFilter": {
          "namespaceIds": [
            ""
          ]
        },
        "outputUrlPrefix": "gs://[YOUR_BUCKET_NAME]"
      },
      "done": true,
      "response": {
        "@type": "type.googleapis.com/google.datastore.admin.v1.ExportEntitiesResponse",
        "outputUrl": "gs://[YOUR_BUCKET_NAME]/2017-05-25T23:54:39_76544/2017-05-25T23:54:39_76544.overall_export_metadata"
      }
    }
  ]
}

我不完全确定你如何区分失败的作业,不过,我想 response 字段中会显示一些不同的东西。