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

Conversation

bflad
Copy link
Member

@bflad bflad commented May 4, 2022

Verified with terraform-provider-corner. Creating unit testing for this setup requires something like hashicorp/terraform-plugin-log#61 upstream. The missing root fields (which are present in the old logging since it fallsback to the root SDK logger) can be resolved once terraform-plugin-log v0.4.0 is released, this module is updated for that dependency, and it can use the WithRootFields() option when creating the framework subsystem logger.

Previously:

2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Calling provider defined Provider GetResources: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange
2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Called provider defined Provider GetResources: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange
2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Calling provider defined ResourceType GetSchema: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange

Now:

2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Calling provider defined Provider GetResources
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Called provider defined Provider GetResources
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Calling provider defined ResourceType GetSchema
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Called provider defined ResourceType GetSchema

…y RPC logic

Verified with terraform-provider-corner. Creating unit testing for this setup requires something like hashicorp/terraform-plugin-log#61 upstream.

Previously:

```text
2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Calling provider defined Provider GetResources: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange
2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Called provider defined Provider GetResources: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange
2022-05-03T13:38:24.417-0400 [DEBUG] sdk.framework: Calling provider defined ResourceType GetSchema: new_logger_warning="This log was generated by an SDK subsystem logger that wasn't created before being used. Use tflog.NewSubsystem to create this logger before it is used." tf_provider_addr=registry.terraform.io/hashicorp/framework tf_req_id=44608b15-0686-e9f9-1d17-56ca3c63b336 tf_resource_type=framework_user tf_rpc=ApplyResourceChange
```

Now:

```text
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Calling provider defined Provider GetResources
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Called provider defined Provider GetResources
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Calling provider defined ResourceType GetSchema
2022-05-04T09:21:20.515-0400 [DEBUG] sdk.framework: Called provider defined ResourceType GetSchema
```
@bflad bflad added the bug Something isn't working label May 4, 2022
@bflad bflad added this to the v0.8.0 milestone May 4, 2022
@bflad bflad requested a review from a team as a code owner May 4, 2022 13:51
@bflad bflad merged commit 2529cb0 into main May 4, 2022
@bflad bflad deleted the bflad-proto6server-logging-initcontext branch May 4, 2022 14:56
@github-actions
Copy link

github-actions bot commented Jun 4, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants