kubernetes-sigs/image-builder

OVA post-processor is broken

johananl opened this issue · 3 comments

What steps did you take and what happened:

Run make build-node-ova-vsphere-ubuntu-2004 (or any other OVA build) against some vSphere environment. After the image is built on vSphere and a VMDK file is downloaded, the Packer post-processor named vsphere fails with the following error:

==> vsphere: Running post-processor: packer-manifest (type manifest)
==> vsphere: Running post-processor: vsphere (type shell-local)
==> vsphere (shell-local): Running local shell script: /tmp/packer-shell294747125
    vsphere (shell-local): image-build-ova: cd .
    vsphere (shell-local): image-build-ova: loaded ubuntu-2004-kube-v1.24.2
    vsphere (shell-local): image-build-ova: create ovf ubuntu-2004-kube-v1.24.2.ovf
==> vsphere (shell-local): Traceback (most recent call last):
==> vsphere (shell-local):   File "../../hack/image-build-ova.py", line 270, in <module>
==> vsphere (shell-local):     main()
==> vsphere (shell-local):   File "../../hack/image-build-ova.py", line 182, in main
==> vsphere (shell-local):     create_ovf(ovf, data, ovf_template)
==> vsphere (shell-local):   File "../../hack/image-build-ova.py", line 232, in create_ovf
==> vsphere (shell-local):     f.write(Template(ovf_template).substitute(data))
==> vsphere (shell-local):   File "/usr/lib/python3.8/string.py", line 126, in substitute
==> vsphere (shell-local):     return self.pattern.sub(convert, self.template)
==> vsphere (shell-local):   File "/usr/lib/python3.8/string.py", line 119, in convert
==> vsphere (shell-local):     return str(mapping[named])
==> vsphere (shell-local): KeyError: 'CUSTOM_ROLE'
==> vsphere: Running post-processor: custom-post-processor (type shell-local)
==> vsphere (shell-local): Running local shell script: /tmp/packer-shell3160150536
Build 'vsphere' errored after 1 hour 3 minutes: 1 error(s) occurred:

* Post-processor failed: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Wait completed after 1 hour 3 minutes

==> Some builds didn't complete successfully and had errors:
--> vsphere: 1 error(s) occurred:

* Post-processor failed: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.
make: *** [Makefile:360: build-node-ova-vsphere-ubuntu-2004] Error 1

What did you expect to happen:

I expected the post-processor to exit cleanly.

Anything else you would like to add:

The issue seems to be in images/capi/hack/image-build-ova.py. On line 232 we're trying to template ovf_template.xml which references a variable named ${CUSTOM_ROLE} with a dict which doesn't have this key:

create_ovf(ovf, data, ovf_template)

f.write(Template(ovf_template).substitute(data))

<Property ovf:userConfigurable="false" ovf:value="${CUSTOM_ROLE}" ovf:type="string" ovf:key="CUSTOM_ROLE"/>

data = {
'BUILD_DATE': build_data['build_date'],
'ARTIFACT_ID': build['artifact_id'],
'BUILD_TIMESTAMP': build_data['build_timestamp'],
'EULA': eula,
'OS_NAME': build_data['os_name'],
'OS_ID': OS_id_map[build_data['guest_os_type']]['id'],
'OS_TYPE': OS_id_map[build_data['guest_os_type']]['type'],
'OS_VERSION': OS_id_map[build_data['guest_os_type']]['version'],
'IB_VERSION': build_data['ib_version'],
'DISK_NAME': vmdk['stream_name'],
'DISK_SIZE': build_data['disk_size'],
'POPULATED_DISK_SIZE': vmdk['size'],
'STREAM_DISK_SIZE': vmdk['stream_size'],
'VMX_VERSION': args.vmx_version,
'DISTRO_NAME': build_data['distro_name'],
'DISTRO_VERSION': build_data['distro_version'],
'DISTRO_ARCH': build_data['distro_arch'],
'NESTEDHV': "false",
'FIRMWARE': build_data['firmware']
}

Environment:

Project (Image Builder for Cluster API, kube-deploy/imagebuilder, konfigadm): image-builder

Additional info for Image Builder for Cluster API related issues:

  • OS (e.g. from /etc/os-release, or cmd /c ver): Ubuntu 20.04 LTS
  • Packer Version: 1.8.0
  • Packer Provider: vsphere-iso
  • Ansible Version: n/a
  • Cluster-api version (if using): n/a
  • Kubernetes version: (use kubectl version): n/a

/kind bug

The CUSTOM_ROLE field was added in 961d782.

/assign

Broken by 0164ced.