From a6ebabfea625456d98ea41d661ae776644ea2fa5 Mon Sep 17 00:00:00 2001 From: Kuba Martin Date: Mon, 23 Oct 2023 15:09:31 +0200 Subject: [PATCH] Improve logging of global provider schema cache hits. (#766) Signed-off-by: Jakub Martin --- internal/plugin/grpc_provider.go | 8 +++++--- internal/plugin6/grpc_provider.go | 8 +++++--- internal/tofu/context_plugins.go | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/plugin/grpc_provider.go b/internal/plugin/grpc_provider.go index ce9763a3d3..889a9e870f 100644 --- a/internal/plugin/grpc_provider.go +++ b/internal/plugin/grpc_provider.go @@ -12,14 +12,15 @@ import ( "github.com/zclconf/go-cty/cty" plugin "github.com/hashicorp/go-plugin" + ctyjson "github.com/zclconf/go-cty/cty/json" + "github.com/zclconf/go-cty/cty/msgpack" + "google.golang.org/grpc" + "github.com/opentofu/opentofu/internal/addrs" "github.com/opentofu/opentofu/internal/logging" "github.com/opentofu/opentofu/internal/plugin/convert" "github.com/opentofu/opentofu/internal/providers" proto "github.com/opentofu/opentofu/internal/tfplugin5" - ctyjson "github.com/zclconf/go-cty/cty/json" - "github.com/zclconf/go-cty/cty/msgpack" - "google.golang.org/grpc" ) var logger = logging.HCLogger() @@ -81,6 +82,7 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp // check the global cache if !p.Addr.IsZero() { if resp, ok := providers.SchemaCache.Get(p.Addr); ok { + logger.Trace("GRPCProvider: GetProviderSchema: serving from global schema cache", "address", p.Addr) return resp } } diff --git a/internal/plugin6/grpc_provider.go b/internal/plugin6/grpc_provider.go index 248e77e859..ceb388b3e8 100644 --- a/internal/plugin6/grpc_provider.go +++ b/internal/plugin6/grpc_provider.go @@ -12,14 +12,15 @@ import ( "github.com/zclconf/go-cty/cty" plugin "github.com/hashicorp/go-plugin" + ctyjson "github.com/zclconf/go-cty/cty/json" + "github.com/zclconf/go-cty/cty/msgpack" + "google.golang.org/grpc" + "github.com/opentofu/opentofu/internal/addrs" "github.com/opentofu/opentofu/internal/logging" "github.com/opentofu/opentofu/internal/plugin6/convert" "github.com/opentofu/opentofu/internal/providers" proto6 "github.com/opentofu/opentofu/internal/tfplugin6" - ctyjson "github.com/zclconf/go-cty/cty/json" - "github.com/zclconf/go-cty/cty/msgpack" - "google.golang.org/grpc" ) var logger = logging.HCLogger() @@ -81,6 +82,7 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp // check the global cache if !p.Addr.IsZero() { if resp, ok := providers.SchemaCache.Get(p.Addr); ok { + logger.Trace("GRPCProvider: GetProviderSchema: serving from global schema cache", "address", p.Addr) return resp } } diff --git a/internal/tofu/context_plugins.go b/internal/tofu/context_plugins.go index 51085e4222..f727c5aae0 100644 --- a/internal/tofu/context_plugins.go +++ b/internal/tofu/context_plugins.go @@ -74,6 +74,7 @@ func (cp *contextPlugins) ProviderSchema(addr addrs.Provider) (providers.Provide // may be able to avoid spinning up the provider instance at all. schemas, ok := providers.SchemaCache.Get(addr) if ok { + log.Printf("[TRACE] tofu.contextPlugins: Serving provider %q schema from global schema cache", addr) return schemas, nil }