Skip to content
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

internal/proto6server: Ensure logging.InitContext is called before any RPC logic #314

Merged
merged 2 commits into from May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/314.txt
@@ -0,0 +1,3 @@
```release-note:bug
all: Prevented `This log was generated by an SDK subsystem logger that wasn't created before being used.` warning messages in logging
```
10 changes: 10 additions & 0 deletions internal/proto6server/serve.go
Expand Up @@ -107,6 +107,7 @@ func (r getProviderSchemaResponse) toTfprotov6() *tfprotov6.GetProviderSchemaRes

func (s *Server) GetProviderSchema(ctx context.Context, _ *tfprotov6.GetProviderSchemaRequest) (*tfprotov6.GetProviderSchemaResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := new(getProviderSchemaResponse)

s.getProviderSchema(ctx, resp)
Expand Down Expand Up @@ -246,6 +247,7 @@ func (r validateProviderConfigResponse) toTfprotov6() *tfprotov6.ValidateProvide

func (s *Server) ValidateProviderConfig(ctx context.Context, req *tfprotov6.ValidateProviderConfigRequest) (*tfprotov6.ValidateProviderConfigResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &validateProviderConfigResponse{
// This RPC allows a modified configuration to be returned. This was
// previously used to allow a "required" provider attribute (as defined
Expand Down Expand Up @@ -359,6 +361,7 @@ func (r configureProviderResponse) toTfprotov6() *tfprotov6.ConfigureProviderRes

func (s *Server) ConfigureProvider(ctx context.Context, req *tfprotov6.ConfigureProviderRequest) (*tfprotov6.ConfigureProviderResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &configureProviderResponse{}

s.configureProvider(ctx, req, resp)
Expand Down Expand Up @@ -415,6 +418,7 @@ func (r validateResourceConfigResponse) toTfprotov6() *tfprotov6.ValidateResourc

func (s *Server) ValidateResourceConfig(ctx context.Context, req *tfprotov6.ValidateResourceConfigRequest) (*tfprotov6.ValidateResourceConfigResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &validateResourceConfigResponse{}

s.validateResourceConfig(ctx, req, resp)
Expand Down Expand Up @@ -543,6 +547,7 @@ func (r upgradeResourceStateResponse) toTfprotov6() *tfprotov6.UpgradeResourceSt

func (s *Server) UpgradeResourceState(ctx context.Context, req *tfprotov6.UpgradeResourceStateRequest) (*tfprotov6.UpgradeResourceStateResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &upgradeResourceStateResponse{}

s.upgradeResourceState(ctx, req, resp)
Expand Down Expand Up @@ -773,6 +778,7 @@ func (r readResourceResponse) toTfprotov6() *tfprotov6.ReadResourceResponse {

func (s *Server) ReadResource(ctx context.Context, req *tfprotov6.ReadResourceRequest) (*tfprotov6.ReadResourceResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &readResourceResponse{}

s.readResource(ctx, req, resp)
Expand Down Expand Up @@ -919,6 +925,7 @@ func (r planResourceChangeResponse) toTfprotov6() *tfprotov6.PlanResourceChangeR

func (s *Server) PlanResourceChange(ctx context.Context, req *tfprotov6.PlanResourceChangeRequest) (*tfprotov6.PlanResourceChangeResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &planResourceChangeResponse{}

s.planResourceChange(ctx, req, resp)
Expand Down Expand Up @@ -1243,6 +1250,7 @@ func normaliseRequiresReplace(ctx context.Context, rs []*tftypes.AttributePath)

func (s *Server) ApplyResourceChange(ctx context.Context, req *tfprotov6.ApplyResourceChangeRequest) (*tfprotov6.ApplyResourceChangeResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &applyResourceChangeResponse{
// default to the prior state, so the state won't change unless
// we choose to change it
Expand Down Expand Up @@ -1538,6 +1546,7 @@ func (r validateDataResourceConfigResponse) toTfprotov6() *tfprotov6.ValidateDat

func (s *Server) ValidateDataResourceConfig(ctx context.Context, req *tfprotov6.ValidateDataResourceConfigRequest) (*tfprotov6.ValidateDataResourceConfigResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &validateDataResourceConfigResponse{}

s.validateDataResourceConfig(ctx, req, resp)
Expand Down Expand Up @@ -1666,6 +1675,7 @@ func (r readDataSourceResponse) toTfprotov6() *tfprotov6.ReadDataSourceResponse

func (s *Server) ReadDataSource(ctx context.Context, req *tfprotov6.ReadDataSourceRequest) (*tfprotov6.ReadDataSourceResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &readDataSourceResponse{}

s.readDataSource(ctx, req, resp)
Expand Down
1 change: 1 addition & 0 deletions internal/proto6server/serve_import.go
Expand Up @@ -152,6 +152,7 @@ func (s *Server) importResourceState(ctx context.Context, req *tfprotov6.ImportR
// ImportResourceState satisfies the tfprotov6.ProviderServer interface.
func (s *Server) ImportResourceState(ctx context.Context, req *tfprotov6.ImportResourceStateRequest) (*tfprotov6.ImportResourceStateResponse, error) {
ctx = s.registerContext(ctx)
ctx = logging.InitContext(ctx)
resp := &importResourceStateResponse{}

s.importResourceState(ctx, req, resp)
Expand Down