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 HTTP 404 Error Response Codes from OPC #44

Open julianfoi opened 7 years ago

julianfoi commented 7 years ago

Terraform Version

Terraform v0.9.11

Affected Resource(s)

opc_compute_image_list_entry

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", "/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:44:27 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:27 [DEBUG] No meta timeoutkey found in Apply() 2017/07/20 15:44:27 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:27 [DEBUG] [go-oracle-terraform]: HTTP POST Req (/storage/volume/): 2017/07/20 15:44:27 [DEBUG] plugin: terraform-provider-opc: 0xc4201023b0 2017/07/20 15:44:27 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:27 [DEBUG] No meta timeoutkey found in Apply() 2017/07/20 15:44:27 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:27 [DEBUG] [go-oracle-terraform]: HTTP POST Req (/imagelist/Compute-orcdevtest1/julian.ortiz@oracle.com/imageList3/entry/): 2017/07/20 15:44:27 [DEBUG] plugin: terraform-provider-opc: 0xc420102550 2017/07/20 15:44:31 [DEBUG] dag/walk: vertex "meta.count-boundary (count boundary fixup)", waiting for: "opc_compute_image_list_entry.images" 2017/07/20 15:44:31 [DEBUG] dag/walk: vertex "root", waiting for: "meta.count-boundary (count boundary fixup)" 2017/07/20 15:44:31 [DEBUG] dag/walk: vertex "provider.opc (close)", waiting for: "opc_compute_image_list_entry.images" 2017/07/20 15:44:32 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:32 [DEBUG] [go-oracle-terraform]: Encountered HTTP (404) Error: {"message": "MachineImage does not exist"} 2017/07/20 15:44:32 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:32 [DEBUG] [go-oracle-terraform]: 1/3 retries left 2017/07/20 15:44:33 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:33 [DEBUG] [go-oracle-terraform]: Encountered HTTP (404) Error: {"message": "Image list /Compute-orcdevtest1/julian.ortiz@oracle.com/imageList3 or image list entry 1 does not exist to create boot volume /Compute-orcdevtest1/julian.ortiz@oracle.com/storageVolume3."} 2017/07/20 15:44:33 [DEBUG] plugin: terraform-provider-opc: 2017/07/20 15:44:33 [DEBUG] [go-oracle-terraform]: 1/3 retries left 2017/07/20 15:44:36 [DEBUG] dag/walk: vertex "meta.count-boundary (count boundary fixup)", waiting for: "opc_compute_image_list_entry.images" 2017/07/20 15:44:36 [DEBUG] dag/walk: vertex "root", waiting for: "meta.count-boundary (count boundary fixup)" 2017/07/20 15:44:36 [DEBUG] dag/walk: vertex "provider.opc (close)", waiting for: "opc_compute_image_list_entry.images" 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalWriteState 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalApplyProvisioners 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalIf 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalWriteState 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalWriteDiff 2017/07/20 15:44:37 [DEBUG] root: eval: terraform.EvalApplyPost 2017/07/20 15:44:37 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

Expected Behavior

Standard output should print correct reason as to why the resource fail to be created.

I.ex " opc_compute_image_list_entry.images: 1 error(s) occurred: machine_image does not exist"

What should have happened?

Actual Behavior

" Error applying plan:

2 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. Create your plan and set value of /oracle/public/OL_7.1_UEKR3_x86_64 as a machine_image name, resource "opc_compute_image_list_entry" "images" { name = "${opc_compute_image_list.images.name}" machine_images = [ "/oracle/public/OL_7.1_UEKR3_x86_64"] version = 1 } 2) terraform plan 3) terraform apply

Important Factoids

References

grubernaut commented 7 years ago

Hey @julianfoi, thanks for the issue!

To clarify, which version of the opc provider are you using, which OS/Arch are you using, and how did you compile/install the plugin?

I'm seeing this currently with the latest version of the OPC provider plugin:

opc_compute_image_list.images: Creating...
  default:     "" => "1"
  description: "" => "foo bar baz"
  name:        "" => "jake-image-list"
opc_compute_image_list.images: Creation complete (ID: jake-image-list)
opc_compute_image_list_entry.images: Creating...
  machine_images.#: "" => "1"
  machine_images.0: "" => "/oracle/public/OL_7.1_UEKR3_x86_64"
  name:             "" => "jake-image-list"
  uri:              "" => "<computed>"
  version:          "" => "1"
Error applying plan:

1 error(s) occurred:

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

* opc_compute_image_list_entry.images: 404: {"message": "MachineImage does not exist"}

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 the above look like a decent error message, or should we work to enhance that error message? Thanks!

scross01 commented 7 years ago

@julianfoi its not clear from the config what you are trying the achieve, are you just trying trying create an storage volume using the public images image /oracle/public/OL_7.1_UEKR3_x86_64

This can be done with just:

resource "opc_compute_storage_volume" "dns" {
  name = "storageVolume2"
  description = "Description for the Bootable Storage Volume"
  size = 500
  bootable = true
  image_list = "/oracle/public/OL_7.1_UEKR3_x86_64"
  image_list_entry = "1"
}

the opc_compute_image_list and opc_compute_image_list_entry resources are for creating a new image list for a private virtual machine images that have been uploaded

@grubernaut I just noticed we don't have a opc_compute_machine_image resource yet (api doc)