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

always set schema caches from provider clients #33543

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Jul 18, 2023

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 without GetProviderSchemaOptional, which allows core to still access the schema from the global cache and prevent repeatedly spinning up providers which don't have GetProviderSchemaOptional set. The client for these providers will have the schema also stored in the client instance to prevent additional GetProviderSchema calls, and act as a flag to ensure that GetProviderSchema has been called at least once.

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.
Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review #33486 - whoops. Looks good, but of course @bflad testing is best here.

@jbardin jbardin merged commit 62ee606 into main Jul 19, 2023
@jbardin jbardin deleted the jbardin/get-schema-client-cache branch July 19, 2023 12:47
@github-actions
Copy link

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 {
Copy link

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.

Copy link
Member Author

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.

Copy link

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants