Skip to content

Improve caching of Instance() configs #1013

@jackwotherspoon

Description

@jackwotherspoon

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.

enable_iam_auth = kwargs.pop("enable_iam_auth", self._enable_iam_auth)
if instance_connection_string in self._instances:
instance = self._instances[instance_connection_string]
if enable_iam_auth != instance._enable_iam_auth:
raise ValueError(
f"connect() called with 'enable_iam_auth={enable_iam_auth}', "
f"but previously used 'enable_iam_auth={instance._enable_iam_auth}'. "
"If you require both for your use case, please use a new "
"connector.Connector object."
)

Metadata

Metadata

Labels

priority: p2Moderately-important priority. 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