aws / aws/eks-anywhere

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

Open
#8,605 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.1k
Forks
328
Avg merge
1d 4h
Merged PRs (30d)
9

Description

**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](https://anywhere.eks.amazonaws.com/docs/osmgmt/artifacts/#build-nutanix-node-images) 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

Contributor guide

Open the contributing guide

Research direction

Start with eks-anywhere-build-tooling/projects/kubernetes-sigs/image-builder/image-builder/images/capi/packer/nutanix/packer.json, especially the vm_disks block, and compare it with projects/kubernetes-sigs/image-builder/packer/nutanix/nutanix.json. Reproduce the image-builder command using only source_image_name, then verify the build succeeds and adds the EKS node image to Prism Central without requiring image_url.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.