mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Improve logging of global provider schema cache hits. (#766)
Signed-off-by: Jakub Martin <kubam@spacelift.io>
This commit is contained in:
parent
e1b3b4ff82
commit
a6ebabfea6
@ -12,14 +12,15 @@ import (
|
|||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
|
|
||||||
plugin "github.com/hashicorp/go-plugin"
|
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/addrs"
|
||||||
"github.com/opentofu/opentofu/internal/logging"
|
"github.com/opentofu/opentofu/internal/logging"
|
||||||
"github.com/opentofu/opentofu/internal/plugin/convert"
|
"github.com/opentofu/opentofu/internal/plugin/convert"
|
||||||
"github.com/opentofu/opentofu/internal/providers"
|
"github.com/opentofu/opentofu/internal/providers"
|
||||||
proto "github.com/opentofu/opentofu/internal/tfplugin5"
|
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()
|
var logger = logging.HCLogger()
|
||||||
@ -81,6 +82,7 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
|||||||
// check the global cache
|
// check the global cache
|
||||||
if !p.Addr.IsZero() {
|
if !p.Addr.IsZero() {
|
||||||
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
||||||
|
logger.Trace("GRPCProvider: GetProviderSchema: serving from global schema cache", "address", p.Addr)
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,15 @@ import (
|
|||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
|
|
||||||
plugin "github.com/hashicorp/go-plugin"
|
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/addrs"
|
||||||
"github.com/opentofu/opentofu/internal/logging"
|
"github.com/opentofu/opentofu/internal/logging"
|
||||||
"github.com/opentofu/opentofu/internal/plugin6/convert"
|
"github.com/opentofu/opentofu/internal/plugin6/convert"
|
||||||
"github.com/opentofu/opentofu/internal/providers"
|
"github.com/opentofu/opentofu/internal/providers"
|
||||||
proto6 "github.com/opentofu/opentofu/internal/tfplugin6"
|
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()
|
var logger = logging.HCLogger()
|
||||||
@ -81,6 +82,7 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
|||||||
// check the global cache
|
// check the global cache
|
||||||
if !p.Addr.IsZero() {
|
if !p.Addr.IsZero() {
|
||||||
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
||||||
|
logger.Trace("GRPCProvider: GetProviderSchema: serving from global schema cache", "address", p.Addr)
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// may be able to avoid spinning up the provider instance at all.
|
||||||
schemas, ok := providers.SchemaCache.Get(addr)
|
schemas, ok := providers.SchemaCache.Get(addr)
|
||||||
if ok {
|
if ok {
|
||||||
|
log.Printf("[TRACE] tofu.contextPlugins: Serving provider %q schema from global schema cache", addr)
|
||||||
return schemas, nil
|
return schemas, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user