diff --git a/builder/alicloud/ecs/step_attach_keypair.go b/builder/alicloud/ecs/step_attach_keypair.go index 9b14a2d88..a6cc01381 100644 --- a/builder/alicloud/ecs/step_attach_keypair.go +++ b/builder/alicloud/ecs/step_attach_keypair.go @@ -22,7 +22,7 @@ func (s *stepAttachKeyPar) Run(state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) config := state.Get("config").(Config) instance := state.Get("instance").(*ecs.InstanceAttributesType) - start := time.Now().Add(120 * time.Second) + timeoutPoint := time.Now().Add(120 * time.Second) for { err := client.AttachKeyPair(&ecs.AttachKeyPairArgs{RegionId: common.Region(config.AlicloudRegion), KeyPairName: keyPairName, InstanceIds: "[\"" + instance.InstanceId + "\"]"}) @@ -30,7 +30,7 @@ func (s *stepAttachKeyPar) Run(state multistep.StateBag) multistep.StepAction { e, _ := err.(*common.Error) if (!(e.Code == "MissingParameter" || e.Code == "DependencyViolation.WindowsInstance" || e.Code == "InvalidKeyPairName.NotFound" || e.Code == "InvalidRegionId.NotFound")) && - time.Now().Before(start) { + time.Now().Before(timeoutPoint) { time.Sleep(5 * time.Second) continue } diff --git a/builder/alicloud/ecs/step_config_security_group.go b/builder/alicloud/ecs/step_config_security_group.go index 4d6b14323..dc8c083b2 100644 --- a/builder/alicloud/ecs/step_config_security_group.go +++ b/builder/alicloud/ecs/step_config_security_group.go @@ -121,11 +121,11 @@ func (s *stepConfigAlicloudSecurityGroup) Cleanup(state multistep.StateBag) { ui := state.Get("ui").(packer.Ui) message(state, "security group") - start := time.Now().Add(120 * time.Second) + timeoutPoint := time.Now().Add(120 * time.Second) for { if err := client.DeleteSecurityGroup(common.Region(s.RegionId), s.SecurityGroupId); err != nil { e, _ := err.(*common.Error) - if e.Code == "DependencyViolation" && time.Now().Before(start) { + if e.Code == "DependencyViolation" && time.Now().Before(timeoutPoint) { time.Sleep(5 * time.Second) continue } diff --git a/builder/alicloud/ecs/step_config_vpc.go b/builder/alicloud/ecs/step_config_vpc.go index 926fc61a4..c4bdd59a3 100644 --- a/builder/alicloud/ecs/step_config_vpc.go +++ b/builder/alicloud/ecs/step_config_vpc.go @@ -78,13 +78,13 @@ func (s *stepConfigAlicloudVPC) Cleanup(state multistep.StateBag) { ui := state.Get("ui").(packer.Ui) message(state, "VPC") - start := time.Now().Add(60 * time.Second) + timeoutPoint := time.Now().Add(60 * time.Second) for { if err := client.DeleteVpc(s.VpcId); err != nil { e, _ := err.(*common.Error) if (e.Code == "DependencyViolation.Instance" || e.Code == "DependencyViolation.RouteEntry" || e.Code == "DependencyViolation.VSwitch" || - e.Code == "DependencyViolation.SecurityGroup") && time.Now().Before(start) { + e.Code == "DependencyViolation.SecurityGroup") && time.Now().Before(timeoutPoint) { time.Sleep(1 * time.Second) continue } diff --git a/builder/alicloud/ecs/step_config_vswitch.go b/builder/alicloud/ecs/step_config_vswitch.go index 0705fb45a..734647e07 100644 --- a/builder/alicloud/ecs/step_config_vswitch.go +++ b/builder/alicloud/ecs/step_config_vswitch.go @@ -130,13 +130,13 @@ func (s *stepConfigAlicloudVSwitch) Cleanup(state multistep.StateBag) { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) message(state, "vSwitch") - start := time.Now().Add(10 * time.Second) + timeoutPoint := time.Now().Add(10 * time.Second) for { if err := client.DeleteVSwitch(s.VSwitchId); err != nil { e, _ := err.(*common.Error) if (e.Code == "IncorrectVSwitchStatus" || e.Code == "DependencyViolation" || e.Code == "DependencyViolation.HaVip" || - e.Code == "IncorretRouteEntryStatus") && time.Now().Before(start) { + e.Code == "IncorretRouteEntryStatus") && time.Now().Before(timeoutPoint) { time.Sleep(1 * time.Second) continue }