hashicorp / packer-plugin-alicloud

Packer plugin for Alibaba Cloud Image Builder
https://www.packer.io/docs/builders/alicloud-ecs
Mozilla Public License 2.0
12 stars 21 forks source link

Null Vaule for Image Tag in Packer 1.4.1 in AliCloud will cause error #134

Open hc-github-team-packer opened 4 months ago

hc-github-team-packer commented 4 months ago

This issue was originally opened by @syy6 in https://github.com/hashicorp/packer/issues/7662 and has been migrated to this repository. The original issue description is below.


Hi All, Just using Packer 1.4.1 in AliCloud to pack below test.json, but got error like below. We have checked with AliCloud support team, it seems that the reason is Packer takes the empty string in Tag segment in JSON as Null and passes the Null value to AliCloud SDK, then the issue will happen. Coudl U please help to check for this issue? Thanks! BR, Yongyuan

Error:

==> alicloud-ecs: Stopping instance: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Waiting instance stopped: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Creating image: packer_basic
==> alicloud-ecs: Adding tags(map[Application: Base BuildID:2019.05.17 Date:2019-05-17T14:54:02+0000 Environment: GIT Commit: Name: Base OS_Version:SLES12.3 Region:cn-shanghai Stream:default Validation:NotRun]) to image: m-uf66na2l6bjsufaa75yz
==> alicloud-ecs: Error Adding tags to image: SDK.ServerError
==> alicloud-ecs: ErrorCode: InvalidTagValue.Malformed
==> alicloud-ecs: Recommend:
==> alicloud-ecs: RequestId: 376249D2-8423-4F2F-9598-09650770758F
==> alicloud-ecs: Message: The specified Tag.n.Value is not valid.
==> alicloud-ecs: Deleting the image and related snapshots because of cancellation or error...
    alicloud-ecs: Detach keypair packer_5ce21f2b-8c04-c23a-6879-968729e560ba from instance: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Deleting EIP because of cancellation or error...
==> alicloud-ecs: Deleting instance because of cancellation or error...
==> alicloud-ecs: Deleting security group because of cancellation or error...
==> alicloud-ecs: Deleting vSwitch because of cancellation or error...
==> alicloud-ecs: Deleting VPC because of cancellation or error...
==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' errored: Error Adding tags to image: SDK.ServerError
ErrorCode: InvalidTagValue.Malformed
Recommend:
RequestId: 376249D2-8423-4F2F-9598-09650770758F
Message: The specified Tag.n.Value is not valid.

==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Error Adding tags to image: SDK.ServerError
ErrorCode: InvalidTagValue.Malformed
Recommend:
RequestId: 376249D2-8423-4F2F-9598-09650770758F
Message: The specified Tag.n.Value is not valid.

==> Builds finished but no artifacts were created.  

test.json

{
  "variables": {
    "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}",
    "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}"
  },
  "builders": [
    {
      "type": "alicloud-ecs",
      "access_key": "{{user `access_key`}}",
      "secret_key": "{{user `secret_key`}}",
      "region": "cn-shanghai",
      "image_name": "packer_basic",
      "source_image": "centos_7_02_64_20G_alibase_20170818.vhd",
      "ssh_username": "root",
      "instance_type": "ecs.t5-lc2m1.nano",
      "internet_charge_type": "PayByTraffic",
      "io_optimized": "true",
      "tags": {
        "Name": "Base",
        "OS_Version": "CentOS",
        "Date": "2019-05-17T14:54:02+0000",
        "BuildID": "2019.05.17",
        "Application": "Base",
        "Region": "cn-shanghai",
        "Environment": "",
        "GIT Commit": "",
        "Stream": "default",
        "Validation": "NotRun"
      }
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "inline": [
        "sleep 30",
        "yum install redis.x86_64 -y"
      ]
    }
  ]
}