From 7cc9aa36ffcb22a8a7f1577cc52781e72ed088ec Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 12 Aug 2013 13:43:52 -0700 Subject: [PATCH] builder/amazon/common: correct logic in deleting secutiry group --- builder/amazon/common/step_security_group.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builder/amazon/common/step_security_group.go b/builder/amazon/common/step_security_group.go index 04c9b9dcf..7bd415202 100644 --- a/builder/amazon/common/step_security_group.go +++ b/builder/amazon/common/step_security_group.go @@ -88,11 +88,12 @@ func (s *StepSecurityGroup) Cleanup(state map[string]interface{}) { var err error for i := 0; i < 5; i++ { _, err = ec2conn.DeleteSecurityGroup(ec2.SecurityGroup{Id: s.createdGroupId}) - if err != nil { - log.Printf("Error deleting security group: %s", err) - time.Sleep(5 * time.Second) - continue + if err == nil { + break } + + log.Printf("Error deleting security group: %s", err) + time.Sleep(5 * time.Second) } if err != nil {