Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically configure and fail-over connections using DNS #842

Open
hessjcg opened this issue Jul 16, 2024 · 0 comments
Open

Automatically configure and fail-over connections using DNS #842

hessjcg opened this issue Jul 16, 2024 · 0 comments
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@hessjcg
Copy link
Contributor

hessjcg commented Jul 16, 2024

Feature Description

The go connector may be configured to connect to a Cloud SQL instance using a DNS name.

When a connection is configured with a DNS name (instead of an instance name), the connector will query the local DNS for a SRV record. The SRV should contain an instance name matching that DNS name. The connector will use the instance name from the SRV record to connect to the Cloud SQL instance.

The connector will periodically query that DNS. If the instance name in the DNS record changes, the connector will terminate all open connections to the old instance. Then, it will reconfigure itself to open connections to the new instance.

This enables several DNS-related features by allowing configuration through DNS.

  • Users can configure their database clients using the domain name instead of the instance name.
  • Users can fail-over database clients when they change the DNS entry for the database instance.

Sample code

No response

Alternatives Considered

No response

Additional Details

No response

@hessjcg hessjcg added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Jul 16, 2024
@hessjcg hessjcg self-assigned this Jul 16, 2024
@hessjcg hessjcg changed the title Automatically configure and fail-over of client connections using DNS Automatically configure and fail-over connections using DNS Jul 16, 2024
hessjcg added a commit that referenced this issue Aug 2, 2024
hessjcg added a commit that referenced this issue Aug 8, 2024
The dialer may be configured to use a DNS name to look up the instance
name instead of configuring the connector with the instance name directly.

Add a DNS TXT record for the Cloud SQL instance to a private DNS server
or a private Google Cloud DNS Zone used by your application. For example:

- Record type: TXT
- Name: `prod-db.mycompany.example.com` – This is the domain name used by the application
- Value: `my-project:region:my-instance` – This is the instance connection name

Configure the dialer with the cloudsqlconn.WithDNSResolver() option.

Open a database connection using the DNS name:

```
db, err := sql.Open(
    "cloudsql-mysql",
    "myuser:mypass@cloudsql-mysql(prod-db.mycompany.example.com)/mydb",
)
```

Part of #842
hessjcg added a commit that referenced this issue Aug 12, 2024
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 10, 2024
hessjcg added a commit that referenced this issue Sep 17, 2024
hessjcg added a commit that referenced this issue Sep 17, 2024
Part of #842

chore: Add domain name to the cloudsql.ConnName struct

feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
hessjcg added a commit that referenced this issue Sep 18, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 19, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 19, 2024
hessjcg added a commit that referenced this issue Sep 19, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 19, 2024
hessjcg added a commit that referenced this issue Sep 19, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 19, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 19, 2024
hessjcg added a commit that referenced this issue Sep 19, 2024
…se all connections and create a new dialer.

chore: Expose the refresh strategy UseIAMAuthN() value to the dialer. 

Part of #842

chore: Add domain name to the cloudsql.ConnName struct

Feat: Check for DNS changes on connect. On change, close all connections and create a new dialer.

feat: Automatially check for DNS changes periodically. On change, close all connections and create a new dialer.

wip: eno changes

wip: eno interface cleanup

wip: convert monitoredInstance to *monitoredInstance
hessjcg added a commit that referenced this issue Sep 20, 2024
hessjcg added a commit that referenced this issue Sep 20, 2024
When a connection is configured using a DNS domain name, the connector will poll the DNS TXT record every 30 seconds. If the value of the DNS record changes, the connector will close all connections to the old instance, and direct new connections to the updated instance.

Fixes of #842
hessjcg added a commit that referenced this issue Sep 20, 2024
hessjcg added a commit that referenced this issue Sep 20, 2024
 (#871)

Add e2e test to verify that connecting with a DNS name works correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant