eks-anywhere icon indicating copy to clipboard operation
eks-anywhere copied to clipboard

Image builder Nutanix builds fail to use base images already in Prism Central

Open jacobbmay opened this issue 1 year ago • 0 comments

What happened: Attempting to follow documentation for building Nutanix images with the image-builder CLI tool and already have a RHEL cloud image imported into Prism Central that I want to build eks node images from. The documentation says you can either set the image_url variable to grab a publicly accessible image or the source_image_name variable to select an image you have already imported into Prism.

When only the source_image_name variable is set and the image_url variable is not included, packer crashes with an "invalid memory address or nil pointer dereference" error.

What you expected to happen: Image builder successfully builds Nutanix images from a base image that has already been imported into Prism without trying to pull the image from a URL if the image_url variable is not provided.

How to reproduce it (as minimally and precisely as possible):

  1. Import a RHEL cloud image into Prism Central to be used as the source image
  2. Follow the docs to build a Nutanix node image and specify the image name of the image already imported to prism for the source_image_name variable
  3. Don't set the variable image_url because the image is already in Prism
  4. Run the image-builder command: image-builder build --os redhat --hypervisor nutanix --release-channel 1-29 --nutanix-config nutanix.json

This should result in packer crashing with the invalid memory address error as soon as the packer build command is started.

Anything else we need to know?: Was able to confirm this is what is happening by looking at the packer file that is being used for the build: eks-anywhere-build-tooling/projects/kubernetes-sigs/image-builder/image-builder/images/capi/packer/nutanix/packer.json. There are no references to the source_image_name variable anywhere in the file.

Lines 26-32 shows the builder attempting to use the image_url variable for the source image even though one wasn't set:

      "vm_disks": {
        "disk_size_gb": "{{user `disk_size_gb`}}",
        "image_type": "DISK_IMAGE",
        "source_image_delete": "{{user `source_image_delete`}}",
        "source_image_force": "{{user `source_image_force`}}",
        "source_image_uri": "{{user `image_url`}}"
      }

After the build failed I edited the variable file eks-anywhere-build-tooling/projects/kubernetes-sigs/image-builder/packer/nutanix/nutanix.json to set the image_url variable to the same value as the image name and then modified the vm_disks block like the following:

      "vm_disks": {
        "disk_size_gb": "{{user `disk_size_gb`}}",
        "image_type": "DISK_IMAGE",
        "source_image_delete": "{{user `source_image_delete`}}",
        "source_image_force": "{{user `source_image_force`}}",
        "source_image_name": "{{user `image_url`}}"
      }

After changing that I reran the same packer build command that the image-builder failed on, it succeeded, and the eks node image was added to Prism.

Environment:

  • image-builder version v0.5.0
  • RHEL 8.10

jacobbmay avatar Aug 14 '24 20:08 jacobbmay