alibaba / packer-provider

Apache License 2.0
92 stars 26 forks source link

Error deleting vpc #33

Closed yujunz closed 5 years ago

yujunz commented 6 years ago

The images created successfully but error deleting VPC.

==> alicloud-ecs: Deleting image snapshots.
==> alicloud-ecs: Creating image: packer-juicefs-node-1522915639
    alicloud-ecs: Detach keypair packer_5ac5d937-5b1c-c17c-23f7-9b739f6f57f7 from instance: i-2ze7zj85weet69vckag2
==> alicloud-ecs: Cleaning up 'EIP'
==> alicloud-ecs: Cleaning up 'instance'
==> alicloud-ecs: Cleaning up 'security group'
==> alicloud-ecs: Cleaning up 'vSwitch'
==> alicloud-ecs: Cleaning up 'VPC'
==> alicloud-ecs: Error deleting vpc, it may still be around: Aliyun API Error: RequestId: 2267AF22-9D65-4730-AB6B-8C41E1420DAC Status Code: 400 Code: Forbbiden Message: Active custom route in vpc.
==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' finished.

The vpc can be deleted from console successfully although it includes a route table.

li-wu commented 6 years ago

@yujunz, did you solve the problem? Thanks.

yujunz commented 6 years ago

No. I didn't go further in this issue.

mosuke5 commented 6 years ago

I also confirmed this error happened.

willmao commented 6 years ago

I also come to meet with this error when building ecs image without any vpc setting.

The reason is that packer does not delete the vswitch before delete the vpc.

My solution is:

  1. create a vpc network and delete the virtual switch in the vpc you created.
  2. set the vpc_id field in the build config json

As you create the vpc manually, packer will not try to delete the vpc and there will no error appear.

@yujunz @li-wu @mosuke5

This should be a bug and need to be fixed.

zhuzhih2017 commented 6 years ago

@yujunz @mosuke5 Packer will try to delete the resource it created, but the resource cleanup has dependence. In generally the dependency result can be cleanup in one minute. I can increase the waiting time to reduce the error like this, but if you can provide more information is better that I can check what's the real reason lead the dependency can't be release in time?

willmao commented 6 years ago

@zhuzhih2017 error log:

alicloud-ecs: Error deleting vpc, it may still be around: Aliyun API Error: RequestId: 5AA4595B-5AF2-41C2-BE1B-CA4506EA38BB Status Code: 400 Code: Forbbiden Message: Active custom route in vpc.

li-wu commented 6 years ago

@zhuzhih2017 here is the error log: alicloud-ecs: Error deleting vpc, it may still be around: Aliyun API Error: RequestId: 2800BBD5-04A3-49C8-85A1-8F6D7148FB0B Status Code: 400 Code: Forbbiden Message: Active custom route in vpc.

@willmao , thanks for providing the workaround. I will have a try.

li-wu commented 6 years ago

@willmao , I tried your solution: create a VPC and delete the virtual switch in it and add and option with vpc_id: <vpc id> but it failed with error: errored: The specified vpc {vpc id} doesn't exist. any suggestion?

willmao commented 6 years ago

@li-wu just make sure the vpc_id field is correctly set.

willmao commented 6 years ago

@li-wu i have made a PR to the packer official repo and fixed this issue.

li-wu commented 6 years ago

@willmao Thanks for providing the fix.

Marcus-James-Adams commented 5 years ago

if this is now fixed should this be closed?