oracle / terraform-provider-oci

Terraform Oracle Cloud Infrastructure provider
https://www.terraform.io/docs/providers/oci/
Mozilla Public License 2.0
758 stars 676 forks source link

DBSystem destroy with no change because of node count #450

Closed RiaanRossouw closed 6 years ago

RiaanRossouw commented 6 years ago

Terraform Version

Terraform v0.11.2

Description:

Deploying a DBSystem works for us. BUT every subsequent terraform plan shows it wants to destroy and re-create based on node count changing from 0 => 1. I am not making a change.

Terraform Plan

$ tf plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. data.oci_identity_availability_domains.ADs: Refreshing state... Terraform will perform the following actions: -/+ oci_database_db_system.DevTestDB01 (new resource required) id: cpu_core_count: "2" => "2" data_storage_percentage: "80" => "80" data_storage_size_in_gb: "0" => database_edition: "ENTERPRISE_EDITION_HIGH_PERFORMANCE" => "ENTERPRISE_EDITION_HIGH_PERFORMANCE" db_home.#: "1" => "1" db_home.0.database.#: "1" => "1" db_home.0.database.0.admin_password: => (attribute changed) db_home.0.database.0.character_set: "AL32UTF8" => "AL32UTF8" db_home.0.database.0.db_name: "dummy" => "dummy" db_home.0.database.0.db_workload: "OLTP" => "OLTP" db_home.0.database.0.ncharacter_set: "" => db_home.0.database.0.pdb_name: "pdb01" => "pdb01" db_home.0.db_version: "12.1.0.2" => "12.1.0.2" db_home.0.display_name: "dummy" => "dummy" disk_redundancy: "NORMAL" => "NORMAL" display_name: "DevTestDB01" => "DevTestDB01" domain: "devtestdb01.easprimaryvcn.oraclevcn.com" => "devtestdb01.easprimaryvcn.oraclevcn.com" hostname: "ocilxeasdbd01" => "ocilxeasdbd01" license_model: "LICENSE_INCLUDED" => "LICENSE_INCLUDED" lifecycle_details: "" => listener_port: "1521" => node_count: "0" => "1" (forces new resource) reco_storage_size_in_gb: "0" => scan_dns_record_id: "" => scan_ip_ids.#: "0" => shape: "BM.DenseIO1.36" => "BM.DenseIO1.36" ssh_public_keys.#: "1" => "1" state: "AVAILABLE" => time_created: "2018-02-08 00:43:59.69 +0000 UTC" => version: "12.1.2.12.1" => vip_ids.#: "0" => Plan: 1 to add, 0 to change, 1 to destroy.
RiaanRossouw commented 6 years ago

Temporarily looks like ignore works for this one. ignore_changes = ["node_count"]

codycushing commented 6 years ago

Can you clarify, are you leaving node_count empty or specifically setting node_count=0? Can you include the relevant snippet of the .tf file please?

RiaanRossouw commented 6 years ago

Sorry for the delayed response. I am setting node count = 1. DBSystem.tf node_count = "${var.DevTestDB01-NodeCount}" variables.tf variable "DevTestDB01-NodeCount" { default = "1" }

alexng-canuck commented 6 years ago

@RiaanRossouw Thanks for the extra info.

I noticed that you hit this issue with the v2.0.6 provider. Can you try with the latest version provider (https://github.com/oracle/terraform-provider-oci/releases/tag/v2.1.1)?

In v2.0.6, the Terraform state file's value for node_count could be erroneously set to 0 due to it being omitted from a state refresh request to the service.

The latest provider's behavior is to continue to store the config value in state if the Terraform refresh omits the node_count. This should help avoid undesirable diffs in this scenario.

RiaanRossouw commented 6 years ago

Thanks for the update I will verify in a new environment as the one I reported this issue on is now semi production and I cant mess around much in there. I will report back once verified.

alexng-canuck commented 6 years ago

Another note worth mentioning. The node_count property doesn't apply to Dense and HighIO shapes because the node count can only be 1 for such shapes.

So you could also avoid this issue by the removing the node_count field from the config.

RiaanRossouw commented 6 years ago

Good idea. It happens to be BM.DenseIO1.36. I plan to test your suggestions on Monday.

RiaanRossouw commented 6 years ago

Hi.

Initially I reported using version v2.0.6. Since I was on v2.0.7 currently I tested: A) With node_count configured still triggers a change stating node count 0 ==> 1. B) Removing node_count completely in my tests works and no change triggered.

I also updated to v2.1.1 and the same is true as for v2.0.7 above. $ tf version Terraform v0.11.3

alexng-canuck commented 6 years ago

Thanks for the information @RiaanRossouw . The recommendation here is to avoid specifying node_count when specifying Dense or HighIO shapes.

Please let us know if you have any other concerns. Otherwise, we can close this issue.

alexng-canuck commented 6 years ago

Closing the issue. The recommendation for the DBSystem resources is not to specify "node_count" for Dense or HighIO shapes.

@RiaanRossouw , let us know if you have other questions.