← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2005125] Re: templater.py: KeyError 'u' on cloud-final.service.tmpl

 

Closing as resolved/invalid, can no longer reproduce.

** Changed in: cloud-init
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/2005125

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

Status in cloud-init:
  Invalid

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/2005125/+subscriptions



References