terraform-provider-ibm icon indicating copy to clipboard operation
terraform-provider-ibm copied to clipboard

ibm_database failed to apply changes

Open DenysChekirda opened this issue 2 years ago • 3 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform IBM Provider Version

Terraform version: Terraform v1.2.1 on darwin_amd64 IBMCloud provider version: 1.41.1

Affected Resource(s)

  • ibm_database

Terraform Configuration Files

Create Database resource with resource allocation using node_* or members_*.

resource "ibm_database" "database" {
  name                         = "test-database"
  location                     = "us-south"
  service                      = "databases-for-postgresql"
  plan                         = "standard"
  resource_group_id            = "Default"
  version                      = "12"
  adminpassword                = "somepassword"
  node_memory_allocation_mb    = "2048"
  node_disk_allocation_mb      = "10240"

  timeouts {
    create = "60m"
    delete = "60m"
    update = "60m"
  }
  service_endpoints = "public-and-private"
}

Update terraform resource to use group instead of members_* or node_*

resource "ibm_database" "database" {
  name                         = "test-database"
  location                     = "us-south"
  service                      = "databases-for-postgresql"
  plan                         = "standard"
  resource_group_id            = "Default"
  version                      = "12"
  adminpassword                = "somepassword"

  group {
    group_id = "member"
    memory { 
      allocation_mb = 2048
    }
    disk { 
      allocation_mb = 10240
    }
  }
  timeouts {
    create = "60m"
    delete = "60m"
    update = "60m"
  }
  service_endpoints = "public-and-private"
}

Debug Output

https://gist.github.com/DenysChekirda/a5845da64b770d7ca31d178b5343f29e

Expected Behavior

Database instance and resource updated successfully.

Actual Behavior

│ Error: Unprocessable Entity
│ 
│   with module.ijc-test-postgres.ibm_database.database,
│   on ../../../../../../../icm-terraform-modules/modules/ibm/postgres/main.tf line 1, in resource "ibm_database" "database":
│    1: resource "ibm_database" "database" {

Also from time to time happen that under Error: Unprocessable Entity I can see badly formatted URL.

2022-06-02T10:11:27.421+0200 [INFO]  provider.terraform-provider-ibm_v1.41.1: 2022/06/02 10:11:27 [DEBUG] PATCH https://api.us-south.databases.cloud.ibm.com/v5/ibm/deployments/crn:v1:bluemix:public:databases-for-postgresql:us-south:a%!F(MISSING)6e532a4450dda5f0243d1a6c819f1197:65d499f4-c343-4c08-bd17-ea7e675b0725::/groups/member: timestamp=2022-06-02T10:11:27.421+0200
2022-06-02T10:11:27.872+0200 [INFO]  provider.terraform-provider-ibm_v1.41.1: 2022/06/02 10:11:27 [Debug] Response:
HTTP/2.0 422 Unprocessable Entity

Steps to Reproduce

  1. Create ibm_database with resource allocation using node_* or members_* arguments.
  2. Update terraform code to use group instead of node_* or members_* arguments.
  • #0000

DenysChekirda avatar Jun 03 '22 10:06 DenysChekirda

@obai-1 can you please take a look into the issue

hkantare avatar Jun 07 '22 08:06 hkantare

@hkantare @obai-1 any updates on this? We still seeing errors on updating existing database deployments from node_* and member_* usage to group.

Detailed logs here: https://gist.github.com/DenysChekirda/b1d8e92f942c086cc5ba3739d9717147 IBMCloud provider version used: v1.42.0

DenysChekirda avatar Jun 29 '22 06:06 DenysChekirda

@DenysChekirda thanks for posting the detailed logs. I took a look at the logs. The error happens when there is no change in the resource values, and still Terraform is trying to do a scaling operation. Agree it is a bug in the code. In the meantime, a workaround will be to make a slight change in the scaling values. For example, choose a different value for memory allocation_mb.

obai-1 avatar Jun 29 '22 14:06 obai-1

@DenysChekirda This bug is fixed in versions >= 1.45.0

lornakelly avatar Nov 11 '22 13:11 lornakelly