templater.py: KeyError 'u' on cloud-final.service.tmpl

Bug #2005125 reported by richard hornsby
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Invalid
Undecided
Unassigned

Bug Description

cloud-init version: 22.4
source: https://launchpad.net/cloud-init/trunk/22.4/+download/cloud-init-22.4.tar.gz
target platform: Rocky Linux 9, aarch64
hypervisor: Parallels 18
error output included at the bottom
--

Have successfully used this same process to build cloud-init during the packer image creation on Rocky (CentOS) 8 for x86 vbox and AMIs for a couple of years, and Rocky 7 before that. Obviously this was done on x86 hardware.

None of this might matter, but for the sake of transparency - I'm now trying to build a Rocky 9 Parallels VM on an M1 mac (so aarch64), as above, using packer. I can't compare to Rocky 8 arm because Parallels won't boot a Rocky 8 arm iso, and virtualbox won't boot much of anything on arm.

cloud-init appears to build (python3 setup.py build) fine, but is crashing during the install phase, trying to do something with a template.

> File "/tmp/packer/cloud-init/cloud-init-22.4/cloudinit/templater.py", line 93, in replacer
> return str(selected_params[key])

I don't think I'm doing anything special. The provisioner script[1] that packer is running to build/install cloud-init is pretty simple.

As to the python error specifically, I see two references to a var named 'u' in cloud-final.service.tmpl:

> ExecStartPost=/bin/sh -c 'u=NetworkManager.service; \
> out=$(systemctl show --property=SubState $u) || exit; \
> [ "$out" = "SubState=running" ] || exit 0; \
> systemctl reload-or-try-restart $u'

but I'm still trying to figure out what the replacer() method is doing when it tries to return and hits the KeyError.

[1] https://gist.github.com/rjhornsby/359ad009d0bd7ff2f6976a97d9b29f20

Error output:

[root@rockylinux-9 cloud-init-22.4]# python3 setup.py install --init-system=systemd
Traceback (most recent call last):
  File "/tmp/packer/cloud-init/cloud-init-22.4/./tools/render-cloudcfg", line 67, in <module>
    main()
  File "/tmp/packer/cloud-init/cloud-init-22.4/./tools/render-cloudcfg", line 63, in main
    templater.render_cloudcfg(args.variant, args.template, args.output)
  File "/tmp/packer/cloud-init/cloud-init-22.4/cloudinit/templater.py", line 171, in render_cloudcfg
    contents = (render_string(contents, tpl_params)).rstrip() + "\n"
  File "/tmp/packer/cloud-init/cloud-init-22.4/cloudinit/templater.py", line 163, in render_string
    return renderer(content, params)
  File "/tmp/packer/cloud-init/cloud-init-22.4/cloudinit/templater.py", line 95, in basic_render
    return BASIC_MATCHER.sub(replacer, content)
  File "/tmp/packer/cloud-init/cloud-init-22.4/cloudinit/templater.py", line 93, in replacer
    return str(selected_params[key])
KeyError: 'u'
Traceback (most recent call last):
  File "/tmp/packer/cloud-init/cloud-init-22.4/setup.py", line 145, in <module>
    "systemd": [
  File "/tmp/packer/cloud-init/cloud-init-22.4/setup.py", line 146, in <listcomp>
    render_tmpl(f)
  File "/tmp/packer/cloud-init/cloud-init-22.4/setup.py", line 121, in render_tmpl
    subprocess.run(
  File "/usr/lib64/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', './tools/render-cloudcfg', 'systemd/cloud-final.service.tmpl', 'RENDERED_TEMPDg9hznmwx/cloud-final.service']' returned non-zero exit status 1.

Revision history for this message
richard hornsby (smoketree) wrote :
Revision history for this message
richard hornsby (smoketree) wrote :

Have mysteriously resolved this while working on what I thought were unrelated dependency/permissions issues in the x86 vbox version of the same box. Wish I had a better answer to provide as to why this was happening, but seems to be fixed now.

Revision history for this message
richard hornsby (smoketree) wrote :

Closing as resolved/invalid, can no longer reproduce.

Changed in cloud-init:
status: New → Invalid
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.