cloud-sql-python-connector icon indicating copy to clipboard operation
cloud-sql-python-connector copied to clipboard

Improve caching of `Instance()` configs

Open jackwotherspoon opened this issue 1 year ago • 1 comments

Currently we cache Instance() configs by instance connection name. Which means we throw an error if users try to connect to the same instance with enable_iam_auth=False and then with enable_iam_auth=True or vice versa. Instead if we hash with the additional iam info we could support both without needing to throw an error.

Alternative: If IAM authn flag has been changed, we force a refresh to get a new cert to avoid duplicating admin API calls.

https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/blob/a8481e01ee12647743ec585c87e39580b252ef9b/google/cloud/sql/connector/connector.py#L222-L231

jackwotherspoon avatar Feb 15 '24 16:02 jackwotherspoon

Also remove instance from cache on bad connections.

jackwotherspoon avatar Mar 12 '24 14:03 jackwotherspoon