Skip to content

r2dbc does not work with cloud run #509

@arscyper007

Description

@arscyper007

Expected Behavior

based on this doc including the cloud-sql connector and setting gcp url as defined below should be working
have tried several variations and it does not connect.
R2DBC URL template: r2dbc:gcp:postgres://<DB_USER>:<DB_PASS>@<CLOUD_SQL_CONNECTION_NAME>/<DATABASE_NAME>

Also have played around with explicitly defining options etc through configuration but no success:
r2dbc:
datasources:
default:
dialect: POSTGRES
username: ${POSTGRES_USER:postgres}
password: ${POSTGRES_PASSWORD:postgres}
schema: postgres
schema-generate: none
url: ${POSTGRES_URL:r2dbc:postgresql://localhost:5433/gcdb}
db-type: postgres
ssl: ${POSTGRES_SSL_ENABLED:false}
options:
driver: pool
protocol: postgresql
acquireRetry: 60
maxSize: ${POSTGRES_POOL_SIZE:2}
minIdle: 1
initialSize: 1
maxIdleTime: PT60M
driver: ${POSTGRES_DRIVER:gcp}

Also tried:

@bean
@singleton
@nAmed("googleConnection")
public ConnectionFactory connectionFactory() {
ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
.option(DRIVER, "gcp")
.option(PROTOCOL, "postgresql")
.option(PASSWORD, "postgres")
.option(USER, "postgres")
.option(DATABASE, "postgres")
.option(HOST, "project:us-central1:db-instance")
.option(SSL, true)
.option(ENABLE_IAM_AUTH, true)

            .build();

    ConnectionFactory connectionFactory = ConnectionFactories.get(options);
    ConnectionPoolConfiguration poolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory)
            .maxSize(10)
            .maxIdleTime(Duration.ofMinutes(30))
            .build();
    return new ConnectionPool(poolConfiguration);
}

Actual Behaviour

Cannot connect to project:us-central1:db-instance/:5432" it works perfectly fine using the jdbc url with jdbc driver for same container

Steps To Reproduce

No response

Environment Information

JDK17

Example Application

No response

Version

4.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions