kubernetes-sigs/image-builder

Unable to override throughput requirement when building gp2 AMI builds

abhay-krishna opened this issue · 2 comments

The packer.json for AMI builds has a throughput field in the block device mappings section with a default value of 125, but this field is valid only for gp3 volumes. I tried building an Ubuntu gp2 AMI by overriding the throughput from a different JSON var-file (ami.json below) by setting it to "" or even null , but in both cases the build failed with the following error message.

Throughput is not available for device /dev/sda1

Only when I removed that field from image-builder's packer.json did the build proceed past this point. But removal also doesn't seem to be a permanent solution because now there's no way of passing throughput in if I do want to build a gp3 volume. Should I be overriding the default value and/or presence of throughput field in some other way?

What steps did you take and what happened:

PACKER_FLAGS="-force" PACKER_LOG=1 PACKER_LOG_PATH=$PWD/packer.log PACKER_VAR_FILES=$PWD/ami.json make -C $PWD/image-builder/images/capi build-ami-ubuntu-2004

Here is my var-file with some override vars

// ami.json
{
  "ami_filter_name": "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*",
  "ami_filter_owners": "amazon",
  "ami_regions": "us-east-1",
  "aws_region": "us-east-1",
  "builder_instance_type": "t3.large",
  "root_device_name": "/dev/sda1",
  "throughput": "",
  "volume_size": "16",
  "volume_type": "gp2",
}

What did you expect to happen:
I am able to override throughput to a non-empty/non-null value and use it to build a gp3 AMI. Similarly, I expected that setting throughput to "" or null in the ami.json would nullify the throughput input and successfully build a gp2 (or any non-gp3, for that matter) AMI.

Maybe I am doing something wrong or this truly is a limitation. Appreciate any help on this!

Environment:
I built this on an Ubuntu 20.04 EC2 instance.

/kind bug

@abhay-krishna Looks like throughput variable should only be provided if gp3 volumes are being used.
If you'd like to use gp2, I suggest you run a jq command to remove the throughput var from the builder config. Since packer does not allow conditionals in the builder config, incompatibilities like this are quite common. There are similar issues for vsphere export, azure custom rg etc.

Thanks @kkeshavamurthy, that makes sense, removing using jq is my current workaround, so I will just script that. Closing this issue.