Running cloud-init collect-logs inside a chroot is not possible

Bug #1766335 reported by Philip Roche
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Scott Moser

Bug Description

When trying to debug boot issues of a GCE instance I mounted a snapshot of it's boot disk on a running instance and tried to run `sudo chroot /home/ubuntu/failedbootdebug/ cloud-init collect-logs`.

This results in the errors below.

Is running collect-logs inside a chroot an expected use case or should I just gather as much as I can from the list @ http://cloudinit.readthedocs.io/en/latest/topics/capabilities.html#cloud-init-collect-logs ?

ubuntu@failed-boot-debug:~$ sudo chroot /home/ubuntu/failedbootdebug/ cloud-init collect-logs
Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 11, in <module>
    load_entry_point('cloud-init==18.2', 'console_scripts', 'cloud-init')()
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 882, in main
    get_uptime=True, func=functor, args=(name, args))
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2395, in log_time
    ret = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.py", line 88, in handle_collect_logs_args
    collect_logs(args.tarfile, args.userdata)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.py", line 81, in collect_logs
    shutil.copytree(CLOUDINIT_RUN_DIR, os.path.join(run_dir, 'cloud-init'))
  File "/usr/lib/python3.6/shutil.py", line 309, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: '/run/cloud-init'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport/report.py", line 546, in add_proc_info
    self['ExecutablePath'] = os.readlink('/proc/' + pid + '/exe')
FileNotFoundError: [Errno 2] No such file or directory: '/proc/1918/exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 109, in apport_excepthook
    pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME'])
  File "/usr/lib/python3/dist-packages/apport/report.py", line 549, in add_proc_info
    raise ValueError('invalid process')
ValueError: invalid process

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/cloud-init", line 11, in <module>
    load_entry_point('cloud-init==18.2', 'console_scripts', 'cloud-init')()
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 882, in main
    get_uptime=True, func=functor, args=(name, args))
  File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2395, in log_time
    ret = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.py", line 88, in handle_collect_logs_args
    collect_logs(args.tarfile, args.userdata)
  File "/usr/lib/python3/dist-packages/cloudinit/cmd/devel/logs.py", line 81, in collect_logs
    shutil.copytree(CLOUDINIT_RUN_DIR, os.path.join(run_dir, 'cloud-init'))
  File "/usr/lib/python3.6/shutil.py", line 309, in copytree
    names = os.listdir(src)
FileNotFoundError: [Errno 2] No such file or directory: '/run/cloud-init'
ubuntu@failed-boot-debug:~$

Related branches

Revision history for this message
Philip Roche (philroche) wrote :
description: updated
Chad Smith (chad.smith)
Changed in cloud-init:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Scott Moser (smoser)
Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=9f5907e1

Changed in cloud-init:
status: In Progress → Fix Committed
Revision history for this message
Scott Moser (smoser) wrote : Fixed in cloud-init version 18.3.

This bug is believed to be fixed in cloud-init in version 18.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
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.