delphix-integrations / terraform-provider-delphix

Repository for Delphix Terraform Provider built on DCT APIs.
https://integrations.delphix.com
11 stars 9 forks source link

HUBS-1603 Plan phase hangs when VDB resource no longer exists #50

Closed kishlay-delphix closed 1 year ago

kishlay-delphix commented 1 year ago

Problem:

When the VDB was deleted from the engine and terraform plan was being executed, the drift detection mechanism in the provider was not working as expected.Even though the VDB was deleted from the remote the state file reference wasn't getting cleaned up resulting in a hang like behaviour.

Solution:

The drift mechanism was fixed and terraform plan was executing as expected.Also we added extra checks to ensure there is no false override of the state file.

Testing

Tested VDB deletion flow and terraform commands `## Creating a VDB using terraform

terraform apply --auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

delphix_vdb.test will be created

Plan: 1 to add, 0 to change, 0 to destroy. delphix_vdb.test: Creating... delphix_vdb.test: Still creating... [10s elapsed] delphix_vdb.test: Still creating... [20s elapsed] delphix_vdb.test: Still creating... [30s elapsed] delphix_vdb.test: Still creating... [40s elapsed] delphix_vdb.test: Still creating... [50s elapsed] delphix_vdb.test: Still creating... [1m0s elapsed] delphix_vdb.test: Still creating... [1m10s elapsed] delphix_vdb.test: Still creating... [1m20s elapsed] delphix_vdb.test: Still creating... [1m30s elapsed] delphix_vdb.test: Still creating... [1m40s elapsed] delphix_vdb.test: Still creating... [1m50s elapsed] delphix_vdb.test: Still creating... [2m0s elapsed] delphix_vdb.test: Still creating... [2m10s elapsed] delphix_vdb.test: Still creating... [2m20s elapsed] delphix_vdb.test: Still creating... [2m30s elapsed] delphix_vdb.test: Still creating... [2m40s elapsed] delphix_vdb.test: Still creating... [2m50s elapsed] delphix_vdb.test: Still creating... [3m0s elapsed] delphix_vdb.test: Creation complete after 3m6s [id=1-ORACLE_DB_CONTAINER-3]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Refresh after deletion of VDB from UI:

kishlay.singh@Kishlay-Singhs-MacBook-Pro michelin % terraform refresh delphix_vdb.test: Refreshing state... [id=1-ORACLE_DB_CONTAINER-3]

Apply after refresh

kishlay.singh@Kishlay-Singhs-MacBook-Pro michelin % terraform apply --auto-approve

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

delphix_vdb.test will be created

Plan: 1 to add, 0 to change, 0 to destroy. delphix_vdb.test: Creating... delphix_vdb.test: Still creating... [10s elapsed] delphix_vdb.test: Still creating... [20s elapsed] delphix_vdb.test: Still creating... [30s elapsed] delphix_vdb.test: Still creating... [40s elapsed] delphix_vdb.test: Still creating... [50s elapsed] delphix_vdb.test: Still creating... [1m0s elapsed] delphix_vdb.test: Still creating... [1m10s elapsed] delphix_vdb.test: Still creating... [1m20s elapsed] delphix_vdb.test: Still creating... [1m30s elapsed] delphix_vdb.test: Still creating... [1m40s elapsed] delphix_vdb.test: Still creating... [1m50s elapsed] delphix_vdb.test: Still creating... [2m0s elapsed] delphix_vdb.test: Still creating... [2m10s elapsed] delphix_vdb.test: Still creating... [2m20s elapsed] delphix_vdb.test: Still creating... [2m30s elapsed] delphix_vdb.test: Creation complete after 2m34s [id=1-ORACLE_DB_CONTAINER-4]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.a`