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

OpenTSDB datasource fields tsdb_resolution and tsdb_version have wrong type #140

Closed
jay7x opened this issue Nov 12, 2020 · 2 comments · Fixed by #398
Closed

OpenTSDB datasource fields tsdb_resolution and tsdb_version have wrong type #140

jay7x opened this issue Nov 12, 2020 · 2 comments · Fixed by #398

Comments

@jay7x
Copy link

jay7x commented Nov 12, 2020

OpenTSDB datasource fields tsdb_resolution and tsdb_version are strings as I see in https://github.com/grafana/terraform-provider-grafana/blob/master/grafana/resource_data_source.go#L149.

Though actually those fields are integers as I see from TF debug output:

plugin.terraform-provider-grafana_v1.7.0:  "jsonData": {
plugin.terraform-provider-grafana_v1.7.0:   "keepCookies": [],
plugin.terraform-provider-grafana_v1.7.0:   "tsdbResolution": 1,
plugin.terraform-provider-grafana_v1.7.0:   "tsdbVersion": 3
plugin.terraform-provider-grafana_v1.7.0:  },

Full version is in gist referred below.

Another confirmation I found here: https://github.com/grafana/grafana/blob/master/devenv/datasources.yaml#L51

It seems our resources were created successfully with v1.5.0 of grafana provider. Today I upgraded it to v1.7.0 and got the error in the middle of terraform plan:

Error: json: cannot unmarshal number into Go struct field JSONData.jsonData.tsdbResolution of type string

Then I tried to downgrade to v1.6.0 but error was still there. I cannot downgrade to v1.5.0 because I imported some teams into the state already. So I'd prefer teams over this particular datasource :)

Terraform Version

Terraform v0.13.3

  • provider registry.terraform.io/grafana/grafana v1.7.0

Affected Resource(s)

  • grafana_data_source

Terraform Configuration Files

resource "grafana_data_source" "aurora-qa-opentsdb" {
  type        = "opentsdb"
  name        = "aurora-qa-opentsdb"
  url         = "http://opentsdb-redacted.example.com:4242"
  access_mode = "proxy"
  json_data {
    tsdb_resolution = 1
    tsdb_version    = 3
  }
}

Debug Output

Unfortunately complete debug output have some sensitive information. So I just posted part of it showing actual JSON data type from Grafana reply. You may see it here: https://gist.github.com/jay7x/712daa1249548a08ecd8c53521bf3031

Expected Behavior

terraform plan should succeed.

Actual Behavior

terraform plan is failed in the middle of state refresh with the following error:

Error: json: cannot unmarshal number into Go struct field JSONData.jsonData.tsdbResolution of type string

Steps to Reproduce

  1. Create OpenTSDB datasource with v1.5.0.
  2. Upgrade to v1.6.0 and run terraform plan.
@jay7x
Copy link
Author

jay7x commented Nov 13, 2020

Well.. I just realised it's defined as a string in https://github.com/grafana/grafana-api-golang-client/blob/master/datasource.go#L61.. So this going to be long story..

I did PR there as well: grafana/grafana-api-golang-client#17. Need that to be merged before it can be fixed here.

julienduchesne pushed a commit to grafana/grafana-api-golang-client that referenced this issue Feb 21, 2022
`tsdb_resolution` and `tsdb_version` were declared as strings though
those fields are integers.

See grafana/terraform-provider-grafana#140
julienduchesne added a commit to grafana/grafana-api-golang-client that referenced this issue Feb 21, 2022
`tsdb_resolution` and `tsdb_version` were declared as strings though
those fields are integers.

See grafana/terraform-provider-grafana#140

Co-authored-by: Yury Bushmelev <yuryb@spgroup.com.sg>
@julienduchesne
Copy link
Member

This is fixed in v1.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants