GCP - 无法更新 Cloud SQL 实例的元数据

问题描述 投票:0回答:2

我收到来自 GKE 上运行的应用程序的以下响应。 请指教。 直到昨天为止,这一切都运行良好。

====================================================== ========================= Cloud SQL SSL 设置 - 允许不安全的连接连接到此实例。

    spring.datasource.url=jdbc:mysql://google/<DB-NAME>?cloudSqlInstance=<INSTANCE-CONN- 
    URL>&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=<USER>&password=<PASS>

        <dependency>
            <groupId>com.google.cloud.sql</groupId>
            <artifactId>mysql-socket-factory</artifactId>
            <version>1.0.15</version>
        </dependency>


Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
Caused by: java.lang.NoSuchMethodError: com.google.common.base.Throwables.throwIfUnchecked(Ljava/lang/Throwable;)V

I 2019-09-22T08:01:28.370430889Z    at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)

I 2019-09-22T08:01:28.370424094Z }

I 2019-09-22T08:01:28.370417350Z   "status" : "PERMISSION_DENIED"

I 2019-09-22T08:01:28.370409799Z   "message" : "Request had insufficient authentication scopes.",

I 2019-09-22T08:01:28.370402379Z   } ],

I 2019-09-22T08:01:28.370378956Z     "reason" : "forbidden"

I 2019-09-22T08:01:28.370371540Z     "message" : "Request had insufficient authentication scopes.",

I 2019-09-22T08:01:28.370364751Z     "domain" : "global",

I 2019-09-22T08:01:28.370358271Z   "errors" : [ {

I 2019-09-22T08:01:28.370351106Z   "code" : 403,

I 2019-09-22T08:01:28.370344017Z {

I 2019-09-22T08:01:28.370207921Z java.lang.RuntimeException: [test:production] **Failed to update metadata for Cloud SQL instance.**
    at com.google.cloud.sql.core.CloudSqlInstance.addExceptionContext(CloudSqlInstance.java:474)
    at com.google.cloud.sql.core.CloudSqlInstance.fetchMetadata(CloudSqlInstance.java:315)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden

spring-boot google-cloud-platform google-cloud-sql
2个回答
2
投票

您似乎遇到了身份验证问题:

“message”:“请求的身份验证范围不足。”

验证用于 Cloud SQL 实例的服务账户是否具有以下 IAM 角色:

  • Cloud SQL Client
    (首选)
  • Cloud SQL Editor
  • Cloud SQL Admin

或至少具有以下 IAM 权限:

  • cloudsql.instances.connect
  • cloudsql.instances.get

(这两个权限也属于

Cloud Client
角色)


1
投票

在 Spring 数据源 url 的末尾添加

useSSL=false

例如

spring.datasource.url=jdbc:mysql://some-ip-address:some-port/Dbname?useSSL=false

© www.soinside.com 2019 - 2024. All rights reserved.