alibaba / packer-provider

Apache License 2.0
92 stars 26 forks source link

unable to delete existing image although image_force_delete is set to true #72

Closed dimasmamot closed 5 years ago

dimasmamot commented 5 years ago

I want to overwrite the image that being buit, I already define the image_force_delete to true yet aliyun still told me this error

Build 'alicloud-ecs' errored: Failed to delete image: Aliyun API Error: RequestId: 9E670E6C-06B9-4253-BBDC-771E6CB5CE1D Status Code: 403 Code: ImageUsingByInstance Message: The specified image has been used to create instances.
chhaj5236 commented 5 years ago

@dimasmamot Which version did you use. You could download the newest version in https://www.packer.io/downloads.html. It should work as expected.

dimasmamot commented 5 years ago

it is 1.3.5 @chhaj5236

edit.

I already change to 1.4.2, and it showed this error

==> alicloud-ecs: Error creating instance: SDK.ServerError
==> alicloud-ecs: ErrorCode: UnknownError
==> alicloud-ecs: Recommend: 
==> alicloud-ecs: RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
==> alicloud-ecs: Message: The request processing has failed due to some unknown error.
==> alicloud-ecs: Deleting security group because of cancellation or error...
==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' errored: Error creating instance: SDK.ServerError
ErrorCode: UnknownError
Recommend: 
RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
Message: The request processing has failed due to some unknown error.

==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Error creating instance: SDK.ServerError
ErrorCode: UnknownError
Recommend: 
RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
Message: The request processing has failed due to some unknown error.

and I switch to 1.4.1 this showed up

==> alicloud-ecs: Stopping instance: i-t4ngxleritx7cb15dut9

==> alicloud-ecs: Waiting instance stopped: i-t4ngxleritx7cb15dut9

==> alicloud-ecs: Deleting duplicated image and snapshot in ap-southeast-1: deployment-ml-merlin-v1.product.image.scoring-core
==> alicloud-ecs: Failed to delete image: SDK.ServerError
==> alicloud-ecs: ErrorCode: ImageUsingByInstance
==> alicloud-ecs: Recommend: 
==> alicloud-ecs: RequestId: 9A0F1B9D-9090-4EDF-8CB3-57FC31436A1B
==> alicloud-ecs: Message: The specified image has been used to create instances.
    alicloud-ecs: Detach keypair packer_5d203d03-4f79-4c5a-b474-fee8003b6beb from instance: i-t4ngxleritx7cb15dut9
==> alicloud-ecs: Deleting instance because of cancellation or error...

==> alicloud-ecs: Deleting security group because of cancellation or error...

==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' errored: Failed to delete image: SDK.ServerError
ErrorCode: ImageUsingByInstance
Recommend: 
RequestId: 9A0F1B9D-9090-4EDF-8CB3-57FC31436A1B
Message: The specified image has been used to create instances.

==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Failed to delete image: SDK.ServerError
ErrorCode: ImageUsingByInstance
Recommend: 
RequestId: 9A0F1B9D-9090-4EDF-8CB3-57FC31436A1B
Message: The specified image has been used to create instances.
chhaj5236 commented 5 years ago

it is 1.3.5 @chhaj5236

edit.

I already change to 1.4.2, and it showed this error

�[1;31m==> alicloud-ecs: Error creating instance: SDK.ServerError
==> alicloud-ecs: ErrorCode: UnknownError
==> alicloud-ecs: Recommend: 
==> alicloud-ecs: RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
==> alicloud-ecs: Message: The request processing has failed due to some unknown error.�[0m
�[1;32m==> alicloud-ecs: Deleting security group because of cancellation or error...�[0m
�[1;32m==> alicloud-ecs: Deleting temporary keypair...�[0m
�[1;31mBuild 'alicloud-ecs' errored: Error creating instance: SDK.ServerError
ErrorCode: UnknownError
Recommend: 
RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
Message: The request processing has failed due to some unknown error.�[0m

==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Error creating instance: SDK.ServerError
ErrorCode: UnknownError
Recommend: 
RequestId: CBB14D21-E39F-4B6F-9B89-BF319E2CFD3B
Message: The request processing has failed due to some unknown error.

This new error is not related to Packer. The status of the image you provided is not valid. You could try another image first or retry after the issue is solved by product team. I'll feedback to you after it is solved.

dimasmamot commented 5 years ago

I'm sorry, by product team means who exactly? I'm not following.

Any idea about the UnknownError ? My .json is not changing at all, why does it show me that error?

thanks a lot for the help tho.

chhaj5236 commented 5 years ago

I'm sorry, by product team means who exactly? I'm not following.

Any idea about the UnknownError ? My .json is not changing at all, why does it show me that error?

thanks a lot for the help tho.

@dimasmamot This error is nothing to do with your json file or Packer. It was returned by Aliyun ECS API. This image should be in proper status now, you could take a retry now.

dimasmamot commented 5 years ago

edit. I'm using 1.4.2 now without unknown error, thanks to you, yet I still can't force delete the image, the flag are already set to true and I'm trying using -force flag too. still show me the error

and yep, thanks about the image status issue fix.

Yet the force delete image still showing me this

==> alicloud-ecs: Stopping instance: i-t4niixeby39wwwrkk6ga
==> alicloud-ecs: Waiting instance stopped: i-t4niixeby39wwwrkk6ga
==> alicloud-ecs: Deleting duplicated image and snapshot in ap-southeast-1: alpha5-test
==> alicloud-ecs: Failed to delete image: SDK.ServerError
==> alicloud-ecs: ErrorCode: ImageUsingByInstance
==> alicloud-ecs: Recommend: 
==> alicloud-ecs: RequestId: 3C9A5DC8-4184-4192-BE5B-1F204BA52DC8
==> alicloud-ecs: Message: The specified image has been used to create instances.
    alicloud-ecs: Detach keypair packer_5d205a70-f848-2923-c5be-61beb7c2fc78 from instance: i-t4niixeby39wwwrkk6ga
==> alicloud-ecs: Deleting instance because of cancellation or error...
==> alicloud-ecs: Deleting security group because of cancellation or error...
==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' errored: Failed to delete image: SDK.ServerError
ErrorCode: ImageUsingByInstance
Recommend: 
RequestId: 3C9A5DC8-4184-4192-BE5B-1F204BA52DC8
Message: The specified image has been used to create instances.

==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Failed to delete image: SDK.ServerError
ErrorCode: ImageUsingByInstance
Recommend: 
RequestId: 3C9A5DC8-4184-4192-BE5B-1F204BA52DC8
Message: The specified image has been used to create instances.
chhaj5236 commented 5 years ago

@dimasmamot That's because you have a image named "alpha5-test" which is already used by a running instance. Packer will try to delete duplicate image if -force is provided, by invoking DeleteImage without setting force option of API. Since deleting images with running instance will have some drawbacks, it could be more safe to do it yourself instead of letting Packer do it for you.

Of course, if the image is not used by any instance, Packer will delete it for you if -force option is provided.

dimasmamot commented 5 years ago

ah I see, I thought force delete image would able to force delete the image whether it's uses by running instance or not. I see it then, okay, its all clear now thanks for your help @chhaj5236 I'm sorry if I ask this in wrong place :pray:

dimasmamot commented 5 years ago

I'm sorry again if I reopen this ticket, I just curious, would packer support the functionality of deleting used image by instance like in this case?

chhaj5236 commented 5 years ago

@dimasmamot This is not considered for now, but might be supported in future (not sure yet). As just mentioned, deleting such images have drawbacks. For example, after the image is deleted, related instance's system disk can not be reset (with original image snapshot) anymore.

dimasmamot commented 5 years ago

yep I'm aware of that, I just need to overwrite the image before I release the current running instance and change it with new one just to reduce the downtime. I guess I'll do it by calling the API then, thanks once again !!!

edit.

Ok I'll close it for real now