pulumi/sdk/go/common/resource/plugin
Abhinav Gupta 5db1fcabeb
sdk/plugin/provider: Prevent use-before-configure races
This is a follow-up to #11975 with a more permanent fix.

The cause of the original data race was that
some of the invocations accessed the configuration
before the Configure RPC succeeded.

Notably, there was a case where we had:

    doStuff(cfg)
    waitForConfiguration()
    doMoreStuff(cfg)

The issue was fixed by simple re-ordering.

    waitForConfiguration()
    doStuff(cfg)
    doMoreStuff(cfg)

However, it remains very easy to read the configuration
before it's actually configured.
It's only a matter of time before the same bug arises again.

To fix this, we pull out the configuration into its own struct,
and make it accessible only by calling a specific function.

This separation is enforced by a promise-like object
with a consumer (Await) and a producer (Fulfill) end.
Any method that needs the configuration must wait for it
with Await first.

NOTE:
Switching to this new method was straightforward
for nearly all methods because they run after Configure.
However, in local experiments, CheckConfig ran before Configure;
DiffConfig looks like it might too.
Both these methods did not have any "wait for configure" blockers
like the other methods,
but they **still used the incorrect configuration**.
I've filled in default values (false) for the configuration parameters
that they consumed before the provider was configured
because that's what they were using anyway.

Refs #11975, #11971
2023-01-27 08:56:42 -08:00
..
analyzer.go feat(engine): Adds structured alias support to the engine 2022-10-11 17:56:32 -04:00
analyzer_plugin.go grpc: WithInsecure is deprecated 2023-01-11 12:15:40 -08:00
check.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
config_source.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
context.go gosimple: select with single case 2023-01-12 09:55:34 -08:00
doc.go Provider implementer's guide draft (#6322) 2021-04-13 14:11:02 -07:00
host.go Improve err message on an invalid plugin override 2023-01-13 12:47:58 -08:00
host_server.go Embed default gRPC server implementations 2023-01-05 17:54:11 -08:00
langruntime.go Engine and Golang support for shimless providers 2022-11-14 11:25:41 +00:00
langruntime_plugin.go Merge #11819 #11834 #11842 #11845 2023-01-12 20:11:42 +00:00
plugin.go Fix port string parsing on Windows 2023-01-19 10:52:30 +00:00
plugin_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
provider.go Phase 3 of the convert mapper 2022-12-01 23:43:43 +00:00
provider_plugin.go sdk/plugin/provider: Prevent use-before-configure races 2023-01-27 08:56:42 -08:00
provider_plugin_test.go sdk/plugin/provider: Prevent use-before-configure races 2023-01-27 08:56:42 -08:00
provider_server.go sdk/resource/ProviderServer: Fix potential panic at Configure 2023-01-12 11:32:42 -08:00
provider_server_test.go sdk/resource/ProviderServer: Fix potential panic at Configure 2023-01-12 11:32:42 -08:00
provider_test.go Add forward compatible UnimplementedProvider for bridge 2022-12-09 18:44:28 -08:00
provider_unimplemented.go sdk/go: Remove 'nolint' directives from package docs 2023-01-06 09:06:47 -08:00
rpc.go [sdk/go] Marshal output values (#7958) 2021-09-27 09:01:40 -07:00
rpc_rapid_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
rpc_test.go sdk/resource/plugin: Don't print from test 2023-01-12 11:31:33 -08:00