PermissionError undefined on python 2.7

Bug #1831146 reported by Benjamin Dean
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Unassigned

Bug Description

running cloud-init-18.5-1.el7.x86_64 on RHEL 7.7

as non-root user when I run `cloud-init status` I get the following error.

Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 9, in <module>
    load_entry_point('cloud-init==18.5', 'console_scripts', 'cloud-init')()
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/main.py", line 892, in main
    get_uptime=True, func=functor, args=(name, args))
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 2520, in log_time
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/cloudinit/cmd/status.py", line 53, in handle_status_args
    init.read_cfg()
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 175, in read_cfg
    self._cfg = self._read_cfg(extra_fns)
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 184, in _read_cfg
    return merger.cfg
  File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 278, in cfg
    self._cfg = self._read_cfg()
  File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 268, in _read_cfg
    cfgs.extend(self._get_instance_configs())
  File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 242, in _get_instance_configs
    except PermissionError:
NameError: global name 'PermissionError' is not defined

seems like it needs some workaround for python 2.7 similar to this one in some other project:
https://github.com/rpm-software-management/mock/commit/46596dfd425a5bac58f51029fdd8c620623e4bb4

Revision history for this message
Benjamin Dean (bdean) wrote :

Here's the commit that added this PermissionError:
https://github.com/cloud-init/cloud-init/commit/fc4b966ba928b30b1c586407e752e0b51b1031e8

in 18.4

Revision history for this message
Ryan Harper (raharper) wrote :

Thanks for submitting the bug.

Changed in cloud-init:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Henry Ford (hrford) wrote :

Hi,
This error still occurs when trying to query for keys as non-root user on an Amazon Linux 2 EC2:
Their cloud-init version is /bin/cloud-init 19.3-3.amzn2

How do I find out if I need to report this to Amazon or this update here is ok?

Revision history for this message
Scott Moser (smoser) wrote :

I'm marking this as 'fix committed'.
In upstream/master at this point it would be considered "Not a bug" as upstream has dropped python2 support.

It is fixed in 'stable-19.4' branch here https://github.com/canonical/cloud-init/commit/c52e94fcc3e610a733a9247d63f9b0967ac4854c .

So the paths to this being fixed for you are:
 a.) amazon cherry-pick that change into their distribution package
 b.) upstream release a 19.5 and amazon pick that up into their distribution package.

Its unfortunate that the change missed the 19.4 release. I don't know if there are upstream plans to release 19.5 or not.

In my opinion, it seems worth reporting to amazon.

Changed in cloud-init:
status: Triaged → Fix Committed
James Falcon (falcojr)
Changed in cloud-init:
status: Fix Committed → Fix Released
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.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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