terraform-providers / terraform-provider-opc

Terraform Oracle Public Cloud provider
https://www.terraform.io/docs/providers/opc/
Mozilla Public License 2.0
29 stars 25 forks source link

Handle of HTTP 409 error messages #43

Open julianfoi opened 7 years ago

julianfoi commented 7 years ago

Terraform Version

Terraform v0.9.11

Affected Resource(s)

opc_compute_image_list.images

Terraform Configuration Files

resource "opc_compute_image_list" "images" {
  name        = "imageList2"
  description = "Description for the Image List"
}

resource "opc_compute_image_list_entry" "images" {
  name           = "${opc_compute_image_list.images.name}"
  machine_images = [ "/oracle/public/OL_7.2_UEKR3_x86_64-17.2.2-20170405-232026", "/Compute-orcdevtest1/opc@oracle.com/myImage"]
  version        = 1
}

resource "opc_compute_storage_volume" "dns" {
  name             = "storageVolume2"
  description      = "Description for the Bootable Storage Volume"
  size             = 500
  bootable         = true
  image_list       = "${opc_compute_image_list.images.name}"
  image_list_entry = "1"
}

Debug Output

2017/07/20 15:24:19 [DEBUG] dag/walk: vertex "provider.opc (close)", waiting for: "opc_compute_storage_volume.dns" 2017/07/20 15:24:20 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:24:20 [DEBUG] [go-oracle-terraform]: Encountered HTTP (409) Error: {"message": "Conflict occurred attempting to store object"} 2017/07/20 15:24:20 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:24:20 [DEBUG] [go-oracle-terraform]: 1/3 retries left 2017/07/20 15:24:24 [DEBUG] dag/walk: vertex "opc_compute_storage_volume.dns", waiting for: "opc_compute_image_list.images" 2017/07/20 15:24:24 [DEBUG] dag/walk: vertex "opc_compute_image_list_entry.images", waiting for: "opc_compute_image_list.images" 2017/07/20 15:24:24 [DEBUG] dag/walk: vertex "meta.count-boundary (count boundary fixup)", waiting for: "opc_compute_storage_volume.dns" 2017/07/20 15:24:24 [DEBUG] dag/walk: vertex "provider.opc (close)", waiting for: "opc_compute_storage_volume.dns" 2017/07/20 15:24:24 [DEBUG] dag/walk: vertex "root", waiting for: "provider.opc (close)" 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalWriteState 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalApplyProvisioners 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalIf 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalWriteState 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalWriteDiff 2017/07/20 15:24:25 [DEBUG] root: eval: terraform.EvalApplyPost 2017/07/20 15:24:25 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

Expected Behavior

Handle HTTP error 409 and provide a detailed description that the resource already existed. Instead of

What should have happened?

Actual Behavior

" Error applying plan:

1 error(s) occurred:

Terraform does not automatically rollback in the face of errors. Instead, your Terraform state file has been partially updated with any resources that successfully completed. Please address the error above and apply again to incrementally change your infrastructure. "

Steps to Reproduce

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

  1. terraform apply
  2. delete terraform.tfstate*
  3. Run terraform apply

Important Factoids

The reason for deleting terraform.tfstates is to reproduce messages that are not clear to the end user as of what could have caused a terraform plan NOT to be applied

References

grubernaut commented 7 years ago

Hey @julianfoi, thanks for the issue!

Going to echo much of what I said in #44, as I'm getting the following output from Terraform using the latest version of the OPC provider plugin:

$ tfa
opc_compute_image_list.images: Creating...
  default:     "" => "1"
  description: "" => "Description for the Image List"
  name:        "" => "imageList2"
Error applying plan:

1 error(s) occurred:

* opc_compute_image_list.images: 1 error(s) occurred:

* opc_compute_image_list.images: 409: {"message": "Conflict occurred attempting to store object"}

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Does this look like expected output, or should we iterate on this further? Thanks!