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

external provider does not log what its trying to do #22

Closed
gtmtech opened this issue Aug 20, 2018 · 5 comments · Fixed by #95
Closed

external provider does not log what its trying to do #22

gtmtech opened this issue Aug 20, 2018 · 5 comments · Fixed by #95
Assignees
Milestone

Comments

@gtmtech
Copy link

gtmtech commented Aug 20, 2018

Terraform-provider-external v1.0.0
Terraform all versions

I'm running a complicated external command. It's not working. What would be really useful in debugging why is that if I set TF_LOG to trace, the provider logs what its attempting to do, so I can reconcile the output, but it doesnt log anything.

This makes debugging so much more difficult than it needs to be. Could we have some debug please?!

@gtmtech
Copy link
Author

gtmtech commented Aug 20, 2018

By "what its attempting to do" - I mean the command its trying to run.

@paultyng
Copy link
Contributor

#36 added trace logging of the output of the command, but still no tracing of the command itself.

@techdragon
Copy link

The fact this has been open for 3 years is ... I'll be honest, both damning and deeply disheartening.

I can't give you a PR because you don't have staff time/resources to review community contributions, and you leave basic functionality that has serious security implications broken for years (I say broken because #36 should never have passed review without also fixing this, I know I would have kicked it back)... when lets be fair... this is at absolute worst 1 days work for a junior developer, heck its probably less than 1 days work even if the junior developer never used GoLang before that's how trivial this is.

@bflad
Copy link
Contributor

bflad commented Dec 14, 2021

Hi @techdragon 👋 This project is maintained by a different set of maintainers and willing to review contributions in this area. We just haven't seen much interest in this issue (e.g. 👍 count) or any submissions so it hasn't been prioritized against other work.

If someone is interested in working on this, there's two options:

Using log.Printf():

log.Printf("[TRACE] Calling Program: %s", cmd.String())

Using the new terraform-plugin-log tflog package:

This is a little bit more of an invasive change to future proof things, but has the benefit of providing much more information in the logs. This requires switching the data source Read functionality to be context aware, then passing that context through tflog calls. If this is done, the JSON result logging should also be updated.

tflog.Trace(ctx, "calling program", "program", cmd.String(), "stdin", string(queryJson))

We are planning to cut a release of this provider shortly for other reasons, so now may be a great time to get something in.

bflad added a commit that referenced this issue Dec 14, 2021
Reference: #14
Reference: #22

This will enable the data source to exit immediately when receiving an interupt signal from Terraform. This also prepares the data source for future enhancements, such as including Terraform Plugin SDK context with logging messages and including additional information in return diagnostics.
bflad added a commit that referenced this issue Dec 15, 2021
Reference: #14
Reference: #22

This will enable the data source to exit immediately when receiving an interupt signal from Terraform. This also prepares the data source for future enhancements, such as including Terraform Plugin SDK context with logging messages and including additional information in return diagnostics.
bflad added a commit that referenced this issue Dec 20, 2021
…g executed

Reference: #22

Provider will now produce trace logging such as:

```
2021-12-20T09:45:21.305-0500 [TRACE] sdk.proto: Received request: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.305-0500 [TRACE] sdk.proto: Calling downstream: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.305-0500 [TRACE] external: Executing external program: tf_data_source_type=external tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource program=/Users/bflad/go/bin/tf-acc-external-data-source
2021-12-20T09:45:21.375-0500 [TRACE] external: Executed external program: tf_data_source_type=external tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource program=/Users/bflad/go/bin/tf-acc-external-data-source output=""
2021-12-20T09:45:21.375-0500 [TRACE] sdk.proto: Called downstream: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.375-0500 [TRACE] sdk.proto: Served request: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
```
@bflad bflad added this to the v2.2.0 milestone Dec 20, 2021
@bflad bflad self-assigned this Dec 20, 2021
@bflad bflad closed this as completed in #95 Dec 20, 2021
bflad added a commit that referenced this issue Dec 20, 2021
…g executed (#95)

Reference: #22

Provider will now produce trace logging such as:

```
2021-12-20T09:45:21.305-0500 [TRACE] sdk.proto: Received request: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.305-0500 [TRACE] sdk.proto: Calling downstream: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.305-0500 [TRACE] external: Executing external program: tf_data_source_type=external tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource program=/Users/bflad/go/bin/tf-acc-external-data-source
2021-12-20T09:45:21.375-0500 [TRACE] external: Executed external program: tf_data_source_type=external tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource program=/Users/bflad/go/bin/tf-acc-external-data-source output=""
2021-12-20T09:45:21.375-0500 [TRACE] sdk.proto: Called downstream: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
2021-12-20T09:45:21.375-0500 [TRACE] sdk.proto: Served request: tf_data_source_type=external tf_proto_version=5 tf_provider_addr=registry.terraform.io/hashicorp/external tf_req_id=f7754152-04ab-826b-3dec-c68af595576a tf_rpc=ReadDataSource
```
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, 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 May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants