Skip to content

Allow use of TCP sockets instead of Unix sockets when using "Automatic instance discovery" #686

Description

@steve-kidreads-app

Feature Request

I suggest a cl flag like this, that would force cloudsql-proxy to use TCP sockets even if Unix sockets are supported:
-tcp=[IP]:[PORT]

Background

When Unix sockets are supported, they are the default:
https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/97815fd45aea66bdd5703e83bcc8cab68f1ef593/cmd/cloud_sql_proxy/cloud_sql_proxy.go#L239-L241

You can override this default, but only if you're willing to also specify the instance:
https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/97815fd45aea66bdd5703e83bcc8cab68f1ef593/cmd/cloud_sql_proxy/cloud_sql_proxy.go#L199

cloudsql-proxy supports "Automatic instance discovery" which is useful:
https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/97815fd45aea66bdd5703e83bcc8cab68f1ef593/cmd/cloud_sql_proxy/cloud_sql_proxy.go#L243-L247

But there is no way to use "Automatic instance discovery" and specify TCP sockets when Unix sockets are supported. No cl switch exists.

Why it would be useful

This would be a useful feature because developers collaborating but using different platforms could use the same dev configuration (i.e. their code points to 127.0.0.1:3600) and rely on automatic instance discovery to proxy that to the correct instance. The benefit of automatic instance discovery in this context is that developers set their active project in gcloud and don't then have to also set it in the cloudsql-proxy cl (or risk having the two out-of-sync). I'm sure that Unix sockets are more performant, but for developer consistency this option would be great.

Caveat

Admittedly, it's not clear what to do in situations where there are multiple instances: do they just get mapped to consecutive ports starting with [PORT]? I don't actually know what "Automatic instance discovery" does today on non-Unix systems. In my use-case, I have one instance per project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions