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

Add support for dynamically updating instance config #1045

Open
kkirchoff opened this issue Dec 9, 2021 · 7 comments
Open

Add support for dynamically updating instance config #1045

kkirchoff opened this issue Dec 9, 2021 · 7 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@kkirchoff
Copy link

kkirchoff commented Dec 9, 2021

Hello. While many of our applications are container based with fixed topologies, we have several use cases that would greatly benefit from dynamic updates. We spoke with @ jonpjenkins from the Google Team and agreed to enter a feature request.

One such use case is a auditing system that needs to scan all of our databases for PII. This system will need to connect to many systems, and the list will need to be updated as new databases are added or switched. The scanners run in GKE, but for some bewildering reason or another, they are persistent and do not run on a 1:1 scanner to job model.

The most basic and effective model that we see is to:

  • Define the configuration as a bucket, GSM or other object that is hosted on a central object service.
  • Provide for a customer to define the object address at startup so that the appropriate configuration flexibility is maintained.
  • Retrieve the configuraion every X seconds or minutes and perform a hot start if it changes.
  • Limit hot starts so as to not cause a restart loop

Many popular servers such as TCP proxies allow for hot restarting by receiving a signal and then:
(a) running a lint check on the new configuration
(b) terminating the listener. Existing connections should continue to persist, using the old configuration and state, but the old daemon cannot receive new connections
(c) starting a new listener and worker pool that will receive new connections with the new configuration.

Apache, Sendmail, squid, Envoy and other processes use this basic reload feature for non-disruptive uploads.

Most of these examples provide easy to replicate hot restarts. I can give you the envoy hot restarted code if you're looking for an example of that. Their documentation is horrendous, but we're running it as a MySQL proxy on prem and we non-disruptively update the entire configuration this way out of the box!

Oh, one more thing:
For containers, it would be great if the configuration checker would kick off the hot restart. Same for GCE, but if you could allow a user to update the local config and manually kick off a hot restart, that would be extra great.

@kkirchoff kkirchoff added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Dec 9, 2021
@enocom enocom changed the title Brief summary of the proposed feature Add support for dynamically updating instance config Dec 10, 2021
@enocom enocom added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Dec 10, 2021
@enocom
Copy link
Member

enocom commented Dec 13, 2021

Just to summarize our conversation elsewhere, right now the closest thing that matches this is instances_metadata. However, this key assumes a Unix socket connection, which doesn't work for clients using TCP connections.

Like the other examples you've note, Go allows users to close a net.Listener without affecting any open connections. So we could be starting listeners on startup. When the configuration changed, we'd close the listener and open new listeners per the configuration.

For containers, it would be great if the configuration checker would kick off the hot restart.

Would you mind elaborating on this? Do you mean that you'd start the proxy with a pointer to the configuration (a GCS object, a Secret Manager secret, etc) and the proxy would set itself up entirely from this configuration? Something like:

$ cloud_sql_proxy --dynamic-config gs://mybucket/config.json

Same for GCE, but if you could allow a user to update the local config and manually kick off a hot restart, that would be extra great.

How would this be different from the example above?

@enocom
Copy link
Member

enocom commented Sep 7, 2022

Adding some additional information here from @davidcollom:

We don't want to specifically name the instances as we dynamically scale up/down read-replicas along with instances as we scale applications within that region.

Additionally we'd like to not restart the proxy when we do this as our applications as this could impact multiple applications at a time and/or additional upstream failures (queries in flight etc)

In terms of V2... It would be nice overall to allow project + labels lookup to give finer grained connections in a dynamic environment.

@enocom
Copy link
Member

enocom commented Nov 18, 2022

Currently, we're thinking about making it possible to dynamically configure instance connection names using:

  • Secret Manager secrets
  • Pub/Sub topics connected to a secret
  • (possibly) Compute Engine Metadata.

The first two are the priority at the moment.

@Goodsmileduck
Copy link

Hi, is there any update for that feature ?

@enocom
Copy link
Member

enocom commented Jan 31, 2023

Not yet. It remains pretty high up on the list and will likely get some attention later this year.

@enocom
Copy link
Member

enocom commented Feb 13, 2023

In the meantime, we have an example that shows how to connect the proxy to secret manager, such that it restarts when a new instance connection name shows up. See https://github.com/GoogleCloudPlatform/cloud-sql-proxy/tree/main/examples/disaster-recovery.

@enocom enocom added priority: p0 Highest priority. Critical issue. P0 implies highest priority. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels May 25, 2023
@enocom
Copy link
Member

enocom commented May 25, 2023

This might be a good solution for people who want to automatically cut over to newly promoted read replicas.

@enocom enocom added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p0 Highest priority. Critical issue. P0 implies highest priority. labels Feb 22, 2024
@enocom enocom assigned jackwotherspoon and unassigned enocom May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in 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

5 participants