Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ubuntu-server-builder opened this issue May 12, 2023 · 3 comments
Closed

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

ubuntu-server-builder opened this issue May 12, 2023 · 3 comments
Labels
launchpad Migrated from Launchpad

Comments

@ubuntu-server-builder
Copy link
Collaborator

This bug was originally filed in Launchpad as LP: #2005125

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = 2023-02-05T22:08:55.671250+00:00
date_created = 2023-02-04T06:00:54.133793+00:00
date_fix_committed = None
date_fix_released = None
id = 2005125
importance = undecided
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/2005125
milestone = None
owner = smoketree
owner_name = richard hornsby
private = False
status = invalid
submitter = smoketree
submitter_name = richard hornsby
tags = []
duplicates = []

Launchpad user richard hornsby(smoketree) wrote on 2023-02-04T06:00:54.133793+00:00

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
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
"systemd": [
File "/tmp/packer/cloud-init/cloud-init-22.4/setup.py", line 146, in
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.

@ubuntu-server-builder ubuntu-server-builder added the launchpad Migrated from Launchpad label May 12, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user richard hornsby(smoketree) wrote on 2023-02-04T06:00:54.133793+00:00

Launchpad attachments: dmesg and journalctl output

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user richard hornsby(smoketree) wrote on 2023-02-05T22:07:30.400620+00:00

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.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user richard hornsby(smoketree) wrote on 2023-02-05T22:08:55.104114+00:00

Closing as resolved/invalid, can no longer reproduce.

@ubuntu-server-builder ubuntu-server-builder closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad
Projects
None yet
Development

No branches or pull requests

1 participant