Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provider/digitalocean: Fixing the DigitalOcean Droplet 404 potential on refresh of state #3768

Merged
merged 3 commits into from
Nov 5, 2015

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Nov 5, 2015

Fixes #3670

Changing the DigitalOcean Droplet resource to use the new SDK message response when a Droplet isn't found

Current behavious in master:

digitalocean_droplet.foobar: Refreshing state... (ID: 8624387)
Error refreshing state: 1 error(s) occurred:

* digitalocean_droplet.foobar: Error retrieving droplet: GET https://api.digitalocean.com/v2/droplets/8624387: 404 The resource you were accessing could not be found.

Then changing the code to cater for the new API lets me do the following:

terraform refresh
digitalocean_droplet.foobar: Refreshing state... (ID: 8624387)
bin % terraform plan
Refreshing Terraform state prior to plan...


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ digitalocean_droplet.foobar
    image:                "" => "centos-5-8-x32"
    ipv4_address:         "" => "<computed>"
    ipv4_address_private: "" => "<computed>"
    ipv6_address:         "" => "<computed>"
    ipv6_address_private: "" => "<computed>"
    locked:               "" => "<computed>"
    name:                 "" => "foo"
    region:               "" => "nyc3"
    size:                 "" => "512mb"
    status:               "" => "<computed>"
    user_data:            "" => "foobar"


Plan: 1 to add, 0 to change, 0 to destroy.

@catsby
Copy link
Contributor

catsby commented Nov 5, 2015

can we check a status code here? Does it provide a 404 ?

@catsby catsby added the waiting-response An issue/pull request is waiting for a response from the community label Nov 5, 2015
@stack72
Copy link
Contributor Author

stack72 commented Nov 5, 2015

@catsby testing this now...

@stack72
Copy link
Contributor Author

stack72 commented Nov 5, 2015

@catsby you are indeed correct - just changed to the 404 status code:

terraform apply
digitalocean_droplet.foobar: Creating...
  image:                "" => "centos-5-8-x32"
  ipv4_address:         "" => "<computed>"
  ipv4_address_private: "" => "<computed>"
  ipv6_address:         "" => "<computed>"
  ipv6_address_private: "" => "<computed>"
  locked:               "" => "<computed>"
  name:                 "" => "foo"
  region:               "" => "nyc3"
  size:                 "" => "512mb"
  status:               "" => "<computed>"
  user_data:            "" => "foobar"
digitalocean_droplet.foobar: Creation complete

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

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate
bin % terraform refresh
digitalocean_droplet.foobar: Refreshing state... (ID: 8626268)
bin % terraform plan
Refreshing Terraform state prior to plan...


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ digitalocean_droplet.foobar
    image:                "" => "centos-5-8-x32"
    ipv4_address:         "" => "<computed>"
    ipv4_address_private: "" => "<computed>"
    ipv6_address:         "" => "<computed>"
    ipv6_address_private: "" => "<computed>"
    locked:               "" => "<computed>"
    name:                 "" => "foo"
    region:               "" => "nyc3"
    size:                 "" => "512mb"
    status:               "" => "<computed>"
    user_data:            "" => "foobar"


Plan: 1 to add, 0 to change, 0 to destroy.

@catsby
Copy link
Contributor

catsby commented Nov 5, 2015

Awesome! I think I mentioned this in another PR (well, I know I did, but I lose track of which are yours since you've sent so many 😄 ) but we should log that we couldn't find the specific d.Id() here, right before we d.SetId("")

If you could tack that on, we'll merge this

@stack72
Copy link
Contributor Author

stack72 commented Nov 5, 2015

@catsby sorry! Added now :)

@catsby
Copy link
Contributor

catsby commented Nov 5, 2015

LGTM, merging, thanks!

8bitdance

catsby added a commit that referenced this pull request Nov 5, 2015
provider/digitalocean: Fixing the DigitalOcean Droplet 404 potential on refresh of state
@catsby catsby merged commit c811dc9 into hashicorp:master Nov 5, 2015
@stack72 stack72 deleted the f-digitalocean-droplet-404 branch November 5, 2015 18:26
@ghost
Copy link

ghost commented Apr 30, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug provider/digitalocean waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DigitalOcean destroy does not handle 404 on droplet
2 participants