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/aws: Prevent crashing when deleting ecs_service which is gone #3914

Merged
merged 2 commits into from
Nov 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions builtin/providers/aws/resource_aws_ecs_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
}

if len(out.Services) < 1 {
log.Printf("[DEBUG] Removing ECS service %q because it's gone", service.ServiceArn)
Copy link
Contributor

Choose a reason for hiding this comment

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

service here is undefined 😵

1 errors occurred:
--> darwin/amd64 error: exit status 2
Stderr: # github.com/hashicorp/terraform/builtin/providers/aws
builtin/providers/aws/resource_aws_ecs_service.go:159: undefined: service

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fixing this...

Copy link
Member Author

Choose a reason for hiding this comment

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

doh... sorry about that!

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder why Travis didn't pick this up btw.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #3943

Copy link
Member Author

Choose a reason for hiding this comment

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

Thx 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why Travis didn't pick this up btw.

I was wondering the same thing. Very strange 😕 Oh well, it's fixed, thanks for the follow up PR 😄

d.SetId("")
return nil
}

Expand Down Expand Up @@ -247,6 +249,12 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error
if err != nil {
return err
}

if len(resp.Services) == 0 {
log.Printf("[DEBUG] ECS Service %q is already gone", d.Id())
return nil
}

log.Printf("[DEBUG] ECS service %s is currently %s", d.Id(), *resp.Services[0].Status)

if *resp.Services[0].Status == "INACTIVE" {
Expand Down