-
Notifications
You must be signed in to change notification settings - Fork 10.1k
PSS: Use interfaces to configure state stores #37899
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
base: main
Are you sure you want to change the base?
Conversation
…tead of an instance of the `backend.Backend` interface.
…e, instead of directly using methods related to RPCs. This requires changing where we call `SetStateStoreChunkSize`.
To summarize, we don't really need the `SetStateStoreChunkSize` method, and instead methods like `(*GRPCProvider).ConfigureStateStore` in the `plugin6` package can directly inspect the negotiation process that passes through that code and pull out the chunk size. However that means that that code would also need to implement validation. And that's just `(*GRPCProvider).ConfigureStateStore`; what about all the test mocks that are used in different types of test? They would all need to be implemented similarly to GRPCProvider to be good, useful mocks, and then a lot of things that fulfil the provider.Interface interface are coupled to each other. Instead, it's easier to have validation in the `grpcClient` struct's methods in the `remote` package, as that code is common to all scenarios. That code needs a method to 'reach into' the provider.Interface value, so we use the `SetStateStoreChunkSize` method.
97dd6bf to
a38298d
Compare
I'm surprised that removing this doesn't break E2E tests of PSS that use grpcwrap, but I think there's `plugin6` code that runs in that situation, so maybe chunking is handled elsewhere.
| if cs, ok := p.provider.(providers.StateStoreChunkSizeSetter); ok { | ||
| cs.SetStateStoreChunkSize(p.typeName, int(chunkSize)) | ||
| } else { | ||
| // TODO: Remove |
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.
It feels like leaving this in would be helpful, any objections?
| validateResp := provider.ValidateProviderConfig(providers.ValidateProviderConfigRequest{ | ||
| Config: providerConfigVal, | ||
| }) | ||
| diags = diags.Append(validateResp.Diagnostics) | ||
| if diags.HasErrors() { | ||
| return nil, diags | ||
| } | ||
|
|
||
| configureResp := provider.ConfigureProvider(providers.ConfigureProviderRequest{ | ||
| TerraformVersion: tfversion.SemVer.String(), | ||
| Config: providerConfigVal, | ||
| }) | ||
| diags = diags.Append(configureResp.Diagnostics) | ||
| if diags.HasErrors() { | ||
| return nil, diags | ||
| } | ||
|
|
||
| // Validate and configure the state store |
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.
I think this should be behind an interface similar to backend.Backend, and I guess that interface would also live in the pluggable package.
I realised that the code for calling RPC methods had leaked through the code further than intended, so this PR updates calling code in
Metamethods and ensures that configuring a state store is only done via thebackend.Backendinterface.Target Release
1.15.x
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
CHANGELOG entry