-
Notifications
You must be signed in to change notification settings - Fork 353
feat: Support Developer Edition connections #2610
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ | |
| /logs/ | ||
| .tools | ||
| test_results.txt | ||
| test-results | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -584,6 +584,9 @@ the cached copy has expired. Use this setting in environments where the | |
| CPU may be throttled and a background refresh cannot run reliably | ||
| (e.g., Cloud Run)`, | ||
| ) | ||
| localFlags.StringVar(&c.conf.SQLDataEndpoint, "sqldata-api-endpoint", "", | ||
| "Override the SQL Data API endpoint", | ||
| ) | ||
|
|
||
| localFlags.BoolVar(&c.conf.RunConnectionTest, "run-connection-test", false, `Runs a connection test | ||
| against all specified instances. If an instance is unreachable, the Proxy exits with a failure | ||
|
|
@@ -606,6 +609,10 @@ only applicable to Unix sockets)`) | |
| "(*) Connect to the private ip address for all instances") | ||
| localFlags.BoolVar(&c.conf.PSC, "psc", false, | ||
| "(*) Connect to the PSC endpoint for all instances") | ||
| localFlags.BoolVar(&c.conf.SQLDataEnabled, "sql-data", false, | ||
| "Enable SQL Data to tunnel through the Cloud SQL Admin API without"+ | ||
| " needing network access to your public or private IP", | ||
| ) | ||
|
Comment on lines
+612
to
+615
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need some validation if user specify |
||
|
|
||
| return c | ||
| } | ||
|
|
@@ -898,6 +905,7 @@ and re-try with just --auto-iam-authn`) | |
| p, pok := q["port"] | ||
| u, uok := q["unix-socket"] | ||
| up, upok := q["unix-socket-path"] | ||
| sd, sdok := q["sql-data"] | ||
|
|
||
| if aok && uok { | ||
| return newBadCommandError("cannot specify both address and unix-socket query params") | ||
|
|
@@ -955,6 +963,16 @@ and re-try with just --auto-iam-authn`) | |
| } | ||
| ic.UnixSocketPath = up[0] | ||
| } | ||
| if sdok { | ||
| if len(sd) != 1 { | ||
| return newBadCommandError(fmt.Sprintf("sql-data query param should be only one value %q", a)) | ||
| } | ||
| if sd[0] != "true" && sd[0] != "false" { | ||
| return newBadCommandError(fmt.Sprintf("sql-data query param should be \"true\" or \"false\" %q", a)) | ||
| } | ||
| b := sd[0] == "true" | ||
| ic.SQLDataEnabled = &b | ||
| } | ||
|
|
||
| ic.IAMAuthN, err = parseBoolOpt(q, "auto-iam-authn") | ||
| if err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,8 @@ | |
| // necessary. If set, UnixSocketPath takes precedence over UnixSocket, Addr | ||
| // and Port. | ||
| UnixSocketPath string | ||
| // SQLDataEnabled enables connections through the SqlDataService for this connection. | ||
| SQLDataEnabled *bool | ||
| // IAMAuthN enables automatic IAM DB Authentication for the instance. | ||
| // MySQL and Postgres only. If it is nil, the value was not specified. | ||
| IAMAuthN *bool | ||
|
|
@@ -200,6 +202,11 @@ | |
| // of a request context, e.g., Cloud Run. | ||
| LazyRefresh bool | ||
|
|
||
| // SQLDataEnabled configures the dialer to use the SQL Data API. | ||
| SQLDataEnabled bool | ||
| // SQLDataEndpoint configures the endpoint of the SQL Data service. | ||
| SQLDataEndpoint string | ||
|
|
||
| // Instances are configuration for individual instances. Instance | ||
| // configuration takes precedence over global configuration. | ||
| Instances []InstanceConnConfig | ||
|
|
@@ -282,6 +289,9 @@ | |
| if i.IAMAuthN != nil { | ||
| opts = append(opts, cloudsqlconn.WithDialIAMAuthN(*i.IAMAuthN)) | ||
| } | ||
| if i.SQLDataEnabled != nil && *i.SQLDataEnabled || c.SQLDataEnabled { | ||
| opts = append(opts, cloudsqlconn.WithSQLData()) | ||
|
Check failure on line 293 in internal/proxy/proxy.go
|
||
| } | ||
|
|
||
| switch { | ||
| // If private IP is enabled at the instance level, or private IP is enabled globally | ||
|
|
@@ -469,6 +479,10 @@ | |
| opts = append(opts, cloudsqlconn.WithLazyRefresh()) | ||
| } | ||
|
|
||
| if c.SQLDataEndpoint != "" { | ||
| opts = append(opts, cloudsqlconn.WithSQLDataEndpoint(c.SQLDataEndpoint)) | ||
|
Check failure on line 483 in internal/proxy/proxy.go
|
||
| } | ||
|
|
||
| return opts, nil | ||
| } | ||
|
|
||
|
|
@@ -564,8 +578,12 @@ | |
| return configureFUSE(c, conf) | ||
| } | ||
|
|
||
| // unless the proxy is in SqlDataEnabled mode, initiate a refresh operation to warm the cache | ||
| for _, inst := range conf.Instances { | ||
| // Initiate refresh operation and warm the cache. | ||
| // Skip instances with SqlDataEnabled | ||
| if conf.SQLDataEnabled || inst.SQLDataEnabled != nil && *inst.SQLDataEnabled { | ||
| continue | ||
| } | ||
| go func(name string) { _, _ = d.EngineVersion(ctx, name) }(inst.Name) | ||
| } | ||
|
|
||
|
|
@@ -859,6 +877,10 @@ | |
| np = inst.Port | ||
| case conf.Port != 0: | ||
| np = pc.nextPort() | ||
| case conf.SQLDataEnabled || inst.SQLDataEnabled != nil && *inst.SQLDataEnabled: | ||
| // Only Postgres is supported by the SqlDataService | ||
| // when more engines are supported, this code will need to change. | ||
|
Comment on lines
+881
to
+882
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a TODO tag here? |
||
| np = pc.nextDBPort("POSTGRES") | ||
| default: | ||
| version, err := c.dialer.EngineVersion(ctx, inst.Name) | ||
| // Exit if the port is not specified for inactive instance | ||
|
|
@@ -873,10 +895,17 @@ | |
| } else { | ||
| network = "unix" | ||
|
|
||
| version, err := c.dialer.EngineVersion(ctx, inst.Name) | ||
| if err != nil { | ||
| c.logger.Errorf("[%v] could not resolve instance version: %v", inst.Name, err) | ||
| return nil, err | ||
| var version string | ||
| switch { | ||
| case conf.SQLDataEnabled || inst.SQLDataEnabled != nil && *inst.SQLDataEnabled: | ||
| version = "POSTGRES" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this version for? Why do we need the version for SQLDataEnabled? |
||
| default: | ||
| var err error | ||
| version, err = c.dialer.EngineVersion(ctx, inst.Name) | ||
| if err != nil { | ||
| c.logger.Errorf("[%v] could not resolve instance version: %v", inst.Name, err) | ||
| return nil, err | ||
| } | ||
| } | ||
|
|
||
| address, err = newUnixSocketMount(inst, conf.UnixSocket, strings.HasPrefix(version, "POSTGRES")) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be mysqluser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1