GoogleCloudPlatform / cloud-sql-python-connector

A Python library for connecting securely to your Cloud SQL instances.
Apache License 2.0
286 stars 67 forks source link

feat: invalidate cache on bad connection info and IP lookup #1118

Closed jackwotherspoon closed 4 months ago

jackwotherspoon commented 4 months ago

The Connector caches connection info for future connections and schedules refresh operations, however for unrecoverable errors/state we should invalidate the cache to stop future bad refreshes.

We should invalidate the cache on all failed calls to the Cloud SQL Admin APIs, as well as failed IP lookup (preferred IP does not exist).

Added a ._remove_cached method to the Connector to facilitate invalidating the cache.

Closes #1098