-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
always set schema caches from provider clients #33543
Conversation
Allow core to always use the global schema cache, so that providers without GetProviderSchemaOptional are not spun up repeatedly. Rather than conditionally setting the cache, we just conditionally use the cache in the client to work around providers without GetProviderSchemaOptional.
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.
Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch. |
@@ -79,12 +79,14 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp | |||
defer p.mu.Unlock() | |||
|
|||
// check the global cache if we can | |||
if !p.Addr.IsZero() { | |||
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional { |
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.
this breaks the caching. resp
is the zero value, i.e. GetProviderSchemaOptional
is always false.
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.
That is intentional. Caching via GetProviderSchemaOptional
must be opt-in to maintain current behavior with existing provider releases.
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
The logic for skipping the cache was incorrect, causing core to spin up non-GetProviderSchemaOptional providers too often.
Rather than conditionally setting the cache based on
GetProviderSchemaOptional
, we can conditionally use the cache in the client to work around providers withoutGetProviderSchemaOptional
, which allows core to still access the schema from the global cache and prevent repeatedly spinning up providers which don't haveGetProviderSchemaOptional
set. The client for these providers will have the schema also stored in the client instance to prevent additionalGetProviderSchema
calls, and act as a flag to ensure thatGetProviderSchema
has been called at least once.