Search code examples
google-cloud-platformgcloudgoogle-cloud-sql

Cannot create google cloud sql instance using gcloud cli because it is taking too long


I am running the following command using the gcloud cli tool...

gcloud sql instances create sql-db-1 --database-version=MYSQL_8_0 --region=us-central --tier=db-f1-micro

It sits in the terminal for a long time with the following output...

Creating new cloud sql instance...

and then finally fails with...

ERROR: (gcloud.sql.instances.create) Operation https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8 is taking longer than expected. You can continue waiting for the operation by running `gcloud beta sql operations wait --project my-project 0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8`
Status : FAIL 1 b''

This same command was working for me reliably, and then all of a sudden it just started doing this.


Solution

  • When you execute the command line, it creates the Cloud SQL instance, but the CLI throws an ERROR making you think that this wasn’t created; so I opened an issue tracker report for you.

    Meanwhile you can also run after the error:

    gcloud beta sql operations wait --project my-project xxxxxxxxxxxxxxxxxxxxxx

    And wait for the operation to complete. After that, you must see STATUS as DONE:

    NAME                                  TYPE    START                          END                            ERROR  STATUS
    XXXXXXXXXXXXXXXXXXXXXXXXX             CREATE  2022-03-09T21:53:40.532+00:00  2022-03-09T22:06:53.389+00:00  -      DONE
    

    When you open this link in the ERROR:

    https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/0d9534c4-9c70-4a77-86a9-ae5c6d3b5fd8

    You will get:

    {
      "error": {
        "code": 401,
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "errors": [
          {
            "message": "Login Required.",
            "domain": "global",
            "reason": "required",
            "location": "Authorization",
            "locationType": "header"
          }
        ],
        "status": "UNAUTHENTICATED",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.ErrorInfo",
            "reason": "CREDENTIALS_MISSING",
            "domain": "googleapis.com",
            "metadata": {
              "service": "sqladmin.googleapis.com",
              "method": "google.cloud.sql.v1beta4.SqlOperationsService.Get"
            }
          }
        ]
      }
    }