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

resource/ebs_snapshot: fix crash in case of manual deletion #3462

Merged
merged 3 commits into from
Mar 6, 2018

Conversation

loivis
Copy link
Contributor

@loivis loivis commented Feb 20, 2018

Fix #3460

Also enhance error checking in case of any other error.

@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Feb 20, 2018
@ghost ghost added the size/S Managed by automation to categorize the size of a PR. label Feb 20, 2018
@bflad
Copy link
Contributor

bflad commented Feb 21, 2018

The error code change LGTM according to the EC2 API documentation.

Can you add an acceptance test that fails then passes to prevent this in the future and verify your fix? e.g.

{
  Config: //basic
}
{
  PreConfig: func() {
    // SDK call to DeleteSnapshot
  },
  Config: // basic
}

We may also want to have an additional check to remove the ID from the state and return nil if len(res.Snapshots) == 0

@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 21, 2018
return nil
if err != nil {
if isAWSErr(err, "InvalidSnapshot.NotFound", "") {
log.Printf("Snapshot %q Not found - removing from state", d.Id())
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: We tend to prefix such messages with [WARN] so it's easy to find them in the log.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of coz

@ghost ghost added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Feb 21, 2018
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Feb 21, 2018
@ghost ghost added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Feb 21, 2018
@loivis
Copy link
Contributor Author

loivis commented Feb 21, 2018

⎇  echo > aws/debug.log ; and make testacc TEST=./aws TESTARGS='-run=TestAccAWSEBSSnapshot_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSEBSSnapshot_ -timeout 120m
=== RUN   TestAccAWSEBSSnapshot_basic
--- PASS: TestAccAWSEBSSnapshot_basic (141.96s)
=== RUN   TestAccAWSEBSSnapshot_withDescription
--- PASS: TestAccAWSEBSSnapshot_withDescription (47.26s)
=== RUN   TestAccAWSEBSSnapshot_withKms
--- PASS: TestAccAWSEBSSnapshot_withKms (59.23s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	248.498s

@loivis loivis changed the title resource/ebs_snapshot: fix typo on error code checking resource/ebs_snapshot: fix crash in case of manual deletion Feb 21, 2018
@loivis
Copy link
Contributor Author

loivis commented Mar 6, 2018

anything else to change before merge?

@bflad bflad added this to the v1.11.0 milestone Mar 6, 2018
@bflad bflad self-requested a review March 6, 2018 13:56
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks so much! 🚀

=== RUN   TestAccAWSEBSSnapshot_withDescription
--- PASS: TestAccAWSEBSSnapshot_withDescription (33.29s)
=== RUN   TestAccAWSEBSSnapshot_withKms
--- PASS: TestAccAWSEBSSnapshot_withKms (53.12s)
=== RUN   TestAccAWSEBSSnapshot_basic
--- PASS: TestAccAWSEBSSnapshot_basic (84.94s)

}
}

resource "aws_ebs_volume" "test" {
availability_zone = "us-west-2a"
availability_zone = "${data.aws_region.current.name}a"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: Not all regions have/will have AZ a available but this is certainly an improvement (data.aws_availability_zones.current[0].id is safer)

@bflad bflad merged commit e063c51 into hashicorp:master Mar 6, 2018
bflad added a commit that referenced this pull request Mar 6, 2018
@bflad bflad mentioned this pull request Mar 6, 2018
@loivis loivis deleted the 3460-ebs-snapshot-crash branch March 7, 2018 17:39
@bflad
Copy link
Contributor

bflad commented Mar 9, 2018

This has been released in version 1.11.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 7, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash on aws_ebs_snapshot
3 participants