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

[DB Configuration v1] [Terraform 0.12] Type mismatch error. #776

Closed
ghost opened this issue Jun 17, 2019 · 3 comments · Fixed by #1440
Closed

[DB Configuration v1] [Terraform 0.12] Type mismatch error. #776

ghost opened this issue Jun 17, 2019 · 3 comments · Fixed by #1440

Comments

@ghost
Copy link

ghost commented Jun 17, 2019

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see https://www.terraform.io/community.html.

Terraform Version

Terraform v0.12.2

  • provider.openstack v1.19.0

Affected Resource(s)

  • openstack_db_configuration_v1

Terraform Configuration Files

resource "openstack_db_configuration_v1" "mongo" {
  name                  = "equeo-mongo-default"
  description           = "Default MongoDB config for Equeo Backend"
  region                = var.region

  datastore {
    version = var.nosql_datastore_version
    type    = var.nosql_datastore_type
  }

  configuration {
    name  = "storage.wiredTiger.indexConfig.prefixCompression"
    value = tobool("true")
  }
}

Expected Behavior

Resource creates

Actual Behavior

Resource fails to create.

Error: Error creating openstack_db_configuration_v1: Expected HTTP response code [200] when accessing [POST https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/configurations], but got 422 instead
{"unprocessableEntity": {"message": "The value provided for the configuration parameter storage.wiredTiger.indexConfig.prefixCompression is not of type boolean.", "code": 422}}

  on modules/trove/trove.tf line 37, in resource "openstack_db_configuration_v1" "mongo":
  37: resource "openstack_db_configuration_v1" "mongo" {

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

I've also tried passing true without tobool function, which fails exactly the same way.

@jtopjian
Copy link
Contributor

@unb9rn Thank you for reporting this issue.

You might be able to debug this further by doing the following:

$ OS_DEBUG=1 TF_LOG=DEBUG terraform apply

Note the two environment variables before the command.

This will print out the JSON requests and responses. If you aren't able to pinpoint the cause of the type error, can you create a github gist with the sanitized output for us to review?

@ghost
Copy link
Author

ghost commented Jun 17, 2019

module.trove.openstack_db_configuration_v1.mongo: Creating...
2019/06/17 22:40:20 [DEBUG] module.trove.openstack_db_configuration_v1.mongo: applying the planned Create change
2019/06/17 22:40:20 [TRACE] GRPCProvider: ApplyResourceChange
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Region is: RegionOne
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Endpoint for database: https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] openstack_db_configuration_v1 create options: &configurations.CreateOpts{Name:"equeo-mongo-default", Values:map[string]interface {}{"storage.wiredTiger.indexConfig.prefixCompression":"true", "operationProfiling.mode":"off", "storage.wiredTiger.collectionConfig.blockCompressor":"snappy", "storage.wiredTiger.engineConfig.journalCompressor":"snappy"}, Datastore:(*configurations.DatastoreOpts)(0xc0005586c0), Description:"Default MongoDB config for Equeo Backend"}
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Request URL: POST https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/configurations
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Request Headers:
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Accept: application/json
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Content-Type: application/json
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: User-Agent: Terraform/0.12.0 gophercloud/2.0.0
2019-06-17T22:40:20.160+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: X-Auth-Token: ***
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Request Body: {
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:   "configuration": {
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "datastore": {
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "type": "mongodb",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "version": "4.0"
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     },
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "description": "Default MongoDB config for Equeo Backend",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "name": "equeo-mongo-default",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "values": {
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "operationProfiling.mode": "off",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "storage.wiredTiger.collectionConfig.blockCompressor": "snappy",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "storage.wiredTiger.engineConfig.journalCompressor": "snappy",
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:       "storage.wiredTiger.indexConfig.prefixCompression": "true"
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     }
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:   }
2019-06-17T22:40:20.161+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: }
module.nova.openstack_compute_instance_v2.redis: Creating...
2019/06/17 22:40:20 [DEBUG] module.nova.openstack_compute_instance_v2.redis: applying the planned Create change
2019/06/17 22:40:20 [TRACE] GRPCProvider: ApplyResourceChange
2019-06-17T22:40:20.170+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] setting computed for "all_metadata" from ComputedKeys
2019-06-17T22:40:20.170+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Region is: RegionOne
2019-06-17T22:40:20.170+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Endpoint for compute: https://infra.mail.ru:8774/v2.1/
2019-06-17T22:40:20.170+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Region is: RegionOne
2019-06-17T22:40:20.170+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Endpoint for network: https://infra.mail.ru:9696/v2.0/
2019-06-17T22:40:20.171+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Request URL: GET https://infra.mail.ru:9696/v2.0/networks?id=2e8ff5ea-54f7-440f-892b-118281de7e31&status=ACTIVE
2019-06-17T22:40:20.171+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Request Headers:
2019-06-17T22:40:20.171+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Accept: application/json
2019-06-17T22:40:20.171+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: User-Agent: Terraform/0.12.0 gophercloud/2.0.0
2019-06-17T22:40:20.171+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: X-Auth-Token: ***
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Response Code: 422
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Response Headers:
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Content-Length: 176
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Content-Type: application/json; charset=UTF-8
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: Date: Mon, 17 Jun 2019 18:40:20 GMT
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: 2019/06/17 22:40:20 [DEBUG] OpenStack Response Body: {
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:   "unprocessableEntity": {
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "code": 422,
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:     "message": "The value provided for the configuration parameter storage.wiredTiger.indexConfig.prefixCompression is not of type boolean."
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4:   }
2019-06-17T22:40:20.536+0400 [DEBUG] plugin.terraform-provider-openstack_v1.19.0_x4: }
2019/06/17 22:40:20 [DEBUG] module.trove.openstack_db_configuration_v1.mongo: apply errored, but we're indicating that via the Error pointer rather than returning it: Error creating openstack_db_configuration_v1: Expected HTTP response code [200] when accessing [POST https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/configurations], but got 422 instead
{"unprocessableEntity": {"message": "The value provided for the configuration parameter storage.wiredTiger.indexConfig.prefixCompression is not of type boolean.", "code": 422}}
2019/06/17 22:40:20 [TRACE] module.trove: eval: *terraform.EvalMaybeTainted
2019/06/17 22:40:20 [TRACE] EvalMaybeTainted: module.trove.openstack_db_configuration_v1.mongo encountered an error during creation, so it is now marked as tainted
2019/06/17 22:40:20 [TRACE] module.trove: eval: *terraform.EvalWriteState
2019/06/17 22:40:20 [ERROR] module.trove: eval: *terraform.EvalApplyPost, err: Error creating openstack_db_configuration_v1: Expected HTTP response code [200] when accessing [POST https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/configurations], but got 422 instead
{"unprocessableEntity": {"message": "The value provided for the configuration parameter storage.wiredTiger.indexConfig.prefixCompression is not of type boolean.", "code": 422}}
2019/06/17 22:40:20 [ERROR] module.trove: eval: *terraform.EvalSequence, err: Error creating openstack_db_configuration_v1: Expected HTTP response code [200] when accessing [POST https://infra.mail.ru:8779/v1.0/d9cc3d403c8f4d63b1b0d417b92a0f45/configurations], but got 422 instead
{"unprocessableEntity": {"message": "The value provided for the configuration parameter storage.wiredTiger.indexConfig.prefixCompression is not of type boolean.", "code": 422}}
2019/06/17 22:40:20 [TRACE] [walkApply] Exiting eval tree: module.trove.openstack_db_configuration_v1.mongo
2019/06/17 22:40:20 [TRACE] vertex "module.trove.openstack_db_configuration_v1.mongo": visit complete

Looks like it really ignores toobool fucntion and passes string...

@jtopjian
Copy link
Contributor

Actually, it's probably this:

https://github.com/terraform-providers/terraform-provider-openstack/blob/master/openstack/resource_openstack_db_configuration_v1.go#L77

That's converting the value to a string regardless of the input.

We'll have to investigate the best way to proceed here. DBaaS/Trove isn't a service readily available to the developers here, so it might take some time.

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