diff --git a/internal/backend/local/backend_temp_new_runtime.go b/internal/backend/local/backend_temp_new_runtime.go index d91fb2fbeb..37ed2ddfca 100644 --- a/internal/backend/local/backend_temp_new_runtime.go +++ b/internal/backend/local/backend_temp_new_runtime.go @@ -146,7 +146,7 @@ func (b *Local) opPlanWithExperimentalRuntime(stopCtx context.Context, cancelCtx prevRoundState = states.NewState() // this is the first round, starting with an empty state } - plugins := plugins.NewRuntimePlugins(b.ContextOpts.Plugins.Manager(ctx)) + plugins := plugins.NewRuntimePlugins(b.ContextOpts.Plugins.Manager(stopCtx)) evalCtx := &eval.EvalContext{ RootModuleDir: op.ConfigDir, OriginalWorkingDir: b.ContextOpts.Meta.OriginalWorkingDir, @@ -156,16 +156,6 @@ func (b *Local) opPlanWithExperimentalRuntime(stopCtx context.Context, cancelCtx Providers: plugins, Provisioners: plugins, } - defer func() { - // We'll call close with a cancel-free context because we do still - // want to shut the providers down even if we're dealing with - // graceful shutdown after cancellation. - err := plugins.Close(context.WithoutCancel(ctx)) - // If a provider fails to close there isn't really much we can do - // about that... this shouldn't really be possible unless the - // plugin process already exited for some other reason anyway. - log.Printf("[ERROR] plugin shutdown failed: %s", err) - }() // The new config-loading system wants to work in terms of module source // addresses rather than raw local filenames, so we'll ask the diff --git a/internal/engine/plugins/plugins.go b/internal/engine/plugins/plugins.go index d2c615587d..4eea30d3fa 100644 --- a/internal/engine/plugins/plugins.go +++ b/internal/engine/plugins/plugins.go @@ -91,34 +91,34 @@ func NewRuntimePlugins(manager plugins.PluginManager) Plugins { } } -// NewConfiguredProvider implements evalglue.Providers. +// NewConfiguredProvider implements Providers. func (n *newRuntimePlugins) NewConfiguredProvider(ctx context.Context, provider addrs.AbsProviderInstanceCorrect, configVal cty.Value) (providers.Configured, tfdiags.Diagnostics) { diags := n.providers.ConfigureProvider(ctx, provider, configVal) configured := n.providers.ConfiguredProvider(provider) return configured, diags } -// ProviderConfigSchema implements evalglue.Providers. +// ProviderConfigSchema implements Providers. func (n *newRuntimePlugins) ProviderConfigSchema(ctx context.Context, provider addrs.Provider) (*providers.Schema, tfdiags.Diagnostics) { return n.providers.ProviderConfigSchema(ctx, provider) } -// ResourceTypeSchema implements evalglue.Providers. +// ResourceTypeSchema implements Providers. func (n *newRuntimePlugins) ResourceTypeSchema(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string) (*providers.Schema, tfdiags.Diagnostics) { return n.providers.ResourceTypeSchema(ctx, provider, mode, typeName) } -// ValidateProviderConfig implements evalglue.Providers. +// ValidateProviderConfig implements Providers. func (n *newRuntimePlugins) ValidateProviderConfig(ctx context.Context, provider addrs.Provider, configVal cty.Value) tfdiags.Diagnostics { return n.providers.ValidateProviderConfig(ctx, provider, configVal) } -// ValidateResourceConfig implements evalglue.Providers. +// ValidateResourceConfig implements Providers. func (n *newRuntimePlugins) ValidateResourceConfig(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string, configVal cty.Value) tfdiags.Diagnostics { return n.providers.ValidateResourceConfig(ctx, provider, mode, typeName, configVal) } -// ProvisionerConfigSchema implements evalglue.Provisioners. +// ProvisionerConfigSchema implements Provisioners. func (n *newRuntimePlugins) ProvisionerConfigSchema(ctx context.Context, typeName string) (*configschema.Block, tfdiags.Diagnostics) { schema, err := n.provisioners.ProvisionerSchema(typeName) if err != nil { @@ -126,10 +126,3 @@ func (n *newRuntimePlugins) ProvisionerConfigSchema(ctx context.Context, typeNam } return schema, nil } - -// Close terminates any plugins that are managed by this object and are still -// running. -func (n *newRuntimePlugins) Close(ctx context.Context) error { - // TODO use proper close? - return n.providers.Stop(ctx) -} diff --git a/internal/plugins/provider.go b/internal/plugins/provider.go index 6aad8b69c2..43926c1143 100644 --- a/internal/plugins/provider.go +++ b/internal/plugins/provider.go @@ -79,6 +79,4 @@ type ProviderManager interface { CallFunction(ctx context.Context, addr addrs.AbsProviderInstanceCorrect, name string, arguments []cty.Value) (cty.Value, error) CloseProvider(ctx context.Context, addr addrs.AbsProviderInstanceCorrect) error - - Stop(ctx context.Context) error } diff --git a/internal/plugins/provider_manager.go b/internal/plugins/provider_manager.go index de1cdf6195..6678bc51cf 100644 --- a/internal/plugins/provider_manager.go +++ b/internal/plugins/provider_manager.go @@ -72,7 +72,7 @@ func NewProviderManager(ctx context.Context, factories map[addrs.Provider]provid } } - err := manager.Stop(ctx) + err := manager.stop(ctx) if err != nil { log.Printf("[ERROR] Unable to stop provider manager: %s", err.Error()) } @@ -495,7 +495,7 @@ func (p *providerManager) CloseProvider(ctx context.Context, addr addrs.AbsProvi return err } -func (p *providerManager) Stop(ctx context.Context) error { +func (p *providerManager) stop(ctx context.Context) error { p.configuredLock.Lock() defer p.configuredLock.Unlock()