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: prevent new resources when using ID's of image… #13879

Merged
merged 1 commit into from
Apr 27, 2017

Conversation

roidelapluie
Copy link
Contributor

@roidelapluie roidelapluie commented Apr 23, 2017

…s with slugs

When you specify the ID of an image that has a slug, terraform would
store its slug to the state, hence it would always recreate the image.

This commit fixes it by storing the image as an ID when it is specified
by and ID by the user, ignoring the slug.

Closes #12751.
Fixes #12255.

Signed-off-by: Julien Pivotto roidelapluie@inuits.eu

@roidelapluie
Copy link
Contributor Author

ACCEPTANCE TESTS WITH TESTS ONLY (test_droplet.go)

==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/23 18:04:19 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/digitalocean -v -run=TestAccDigitalOceanDroplet_WithID -timeout 120m
=== RUN   TestAccDigitalOceanDroplet_WithID
--- FAIL: TestAccDigitalOceanDroplet_WithID (38.42s)
        testing.go:280: Step 0 error: After applying this step, the plan was not empty:

                DIFF:

                DESTROY/CREATE: digitalocean_droplet.foobar
                  disk:                 "20" => "<computed>"
                  image:                "centos-7-x64" => "22995941" (forces new resource)
                  ipv4_address:         "45.55.154.238" => "<computed>"
                  ipv4_address_private: "" => "<computed>"
                  ipv6_address:         "" => "<computed>"
                  ipv6_address_private: "" => "<computed>"
                  locked:               "false" => "<computed>"
                  name:                 "foo-4889334322092258525" => "foo-4889334322092258525"
                  price_hourly:         "0.00744" => "<computed>"
                  price_monthly:        "5" => "<computed>"
                  region:               "nyc3" => "nyc3"
                  resize_disk:          "true" => "true"
                  size:                 "512mb" => "512mb"
                  status:               "active" => "<computed>"
                  user_data:            "foobar" => "foobar"
                  vcpus:                "1" => "<computed>"

                STATE:

                digitalocean_droplet.foobar:
                  ID = 46676585
                  disk = 20
                  image = centos-7-x64
                  ipv4_address = 45.55.154.238
                  locked = false
                  name = foo-4889334322092258525
                  price_hourly = 0.00744
                  price_monthly = 5
                  region = nyc3
                  resize_disk = true
                  size = 512mb
                  status = active
                  tags.# = 0
                  user_data = foobar
                  vcpus = 1
FAIL
exit status 1
FAIL    github.com/hashicorp/terraform/builtin/providers/digitalocean   38.429s
make: *** [Makefile:49: testacc] Error 1

ACCEPTANCE TESTS WITH ALL CHANGES (droplet_test.go + droplet.go)

make testacc TEST=./builtin/providers/digitalocean TESTARGS='-run=TestAccDigitalOceanDroplet_WithID'  
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/23 18:02:16 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/digitalocean -v -run=TestAccDigitalOceanDroplet_WithID -timeout 120m
=== RUN   TestAccDigitalOceanDroplet_WithID
--- PASS: TestAccDigitalOceanDroplet_WithID (50.56s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/digitalocean   50.564s

I also ran the basic test:

make testacc TEST=./builtin/providers/digitalocean TESTARGS='-run=TestAccDigitalOceanDroplet_Basic'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/23 18:16:05 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/digitalocean -v -run=TestAccDigitalOceanDroplet_Basic -timeout 120m
=== RUN   TestAccDigitalOceanDroplet_Basic
--- PASS: TestAccDigitalOceanDroplet_Basic (49.30s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/digitalocean   49.308s

@roidelapluie
Copy link
Contributor Author

There might be a problem when switching from a snapshot to a distro

@roidelapluie
Copy link
Contributor Author

fixed.

@roidelapluie
Copy link
Contributor Author

current status: ready for review & merge

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor thing in the test, otherwise this LGTM.

{
Config: testAccCheckDigitalOceanDropletConfig_withID(centosID, rInt),
PlanOnly: true,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually refresh the state as part of every test step, so this is not necessary - would you mind removing the second step + Destroy: false?

@radeksimko radeksimko added the waiting-response An issue/pull request is waiting for a response from the community label Apr 27, 2017
@roidelapluie
Copy link
Contributor Author

done

@radeksimko radeksimko removed the waiting-response An issue/pull request is waiting for a response from the community label Apr 27, 2017
@radeksimko
Copy link
Member

@roidelapluie thanks for sending the other PR, would you mind modifying this PR/test too and resolving conflicts?

Thanks

@radeksimko radeksimko added the waiting-response An issue/pull request is waiting for a response from the community label Apr 27, 2017
…s with slugs

When you specify the ID of an image that has a slug, terraform would
store its slug to the state, hence it would always recreate the image.

This commit fixes it by storing the image as an ID when it is specified
by and ID by the user, ignoring the slug.

Closes hashicorp#12751.
Fixes hashicorp#12255.

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
@roidelapluie
Copy link
Contributor Author

done

@radeksimko radeksimko removed the waiting-response An issue/pull request is waiting for a response from the community label Apr 27, 2017
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great, thanks for the short response time, pulling in...

@radeksimko radeksimko merged commit ccb34b7 into hashicorp:master Apr 27, 2017
@ghost
Copy link

ghost commented Apr 13, 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 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DigitalOcean infinite apply loop (forces new resource)
3 participants