Cloudinit fails to find config drive data due to wrong call on stages.Init(ds_deps=[])

Bug #1618094 reported by test
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Undecided
Unassigned

Bug Description

Came across this issue while manually setting up an Ubuntu 14.04 devstack image with the following setup:
dpkg-reconfigure cloud-init
    [*] ConfigDrive: Reads data from Openstack Config Drive

The issue was that with every instance launch, cloud-init would fail to find the config data mounted on a drive on the instance (in particular /dev/sr0) and was not setting up mainly the ssh keys and the rest of the command customizations.
To test the issue, I ran the following command find the culprit:

 root@ubuntu14:/home/test# cloud-init modules --mode=final
 Can not apply stage final, no datasource found! Likely bad things to come!
 ------------------------------------------------------------
 Traceback (most recent call last):
   File "/usr/bin/cloud-init", line 318, in main_modules
  init.fetch()
   File "/usr/lib/python2.7/dist-packages/cloudinit/stages.py", line 308, in fetch
  return self._get_data_source()
   File "/usr/lib/python2.7/dist-packages/cloudinit/stages.py", line 236, in _get_data_source
  pkg_list)
   File "/usr/lib/python2.7/dist-packages/cloudinit/sources/__init__.py", line 263, in find_source
  raise DataSourceNotFoundException(msg)
 DataSourceNotFoundException: Did not find any data source, searched classes: ()

As it stands out, in https://git.launchpad.net/cloud-init/tree/cloudinit/cmd/main.py:346 the stage Init is not properly done:

    init = stages.Init(ds_deps=[], reporter=args.reporter)

the stages.py:61 init however is not properly addressed in this call and thus assigns the empty list with the following line:

    if ds_deps is not None:
        self.ds_deps = ds_deps # which is an empty list in this case

Thus makes cloudinit ommit mounting and searching device drives for the config data.

As a fix, either files can be changed:
    - main.py:346 > init = stages.Init(ds_deps=None, reporter=args.reporter)
    - stages.py:61 > if ds_deps is not None and len(ds_deps) > 0: (not sure if this is used init is used otherwise)

Anyways the first one fixed my problem.

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

Hi,

So i'm confused as to how this solved your problem.
The working path for this code that the ConfigDrive datasource should be found during 'cloud-init init --local', and then during the 'final' stage (upstart or systemd service named 'cloud-final') the datasource should be loaded from the /var/lib/cloud/instance/obj.pkl cache.

The cloud-final stage is behaving as intended by not searching for a datasource at all.

So 2 comments:
a.) you should always have the 'None' datasource in the search list, as if no others are found, it will get users created and ssh keys generated and apply the local config.

b.) Can you reproduce this failure and post a cloud-init-output.log and cloud-init.log ?
I'd like to see them as this *should* have found the ConfigDrive datasource in the local or network stage.

Please provide that info and then set this back to 'New'.

Thanks!

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
test (mcostache) wrote :
Download full text (4.1 KiB)

Hi Scott,

Your reply is much appreciated.
I looked closely on the VM instance booting, and the logs are not pointing to 'cloud-init init' to be failing at boot time, as the network part is set correctly.
/var/log/boot.log >
Cloud-init v. 0.7.5 running 'init' at Thu, 01 Sep 2016 12:09:44 +0000. Up 4.24 seconds.
ci-info: ++++++++++++++++++++++++++Net device info++++++++++++++++++++++++++
...

/var/log/cloud-init.log >
2016-09-01 08:09:42,643 - util.py[DEBUG]: Cloud-init v. 0.7.5 running 'init-local' at Thu, 01 Sep 2016 12:09:42 +0000. Up 2.59 seconds.
2016-09-01 08:09:42,646 - util.py[DEBUG]: Writing to /var/log/cloud-init.log - ab: [420] 0 bytes
2016-09-01 08:09:42,646 - util.py[DEBUG]: Changing the ownership of /var/log/cloud-init.log to 101:4
2016-09-01 08:09:42,646 - util.py[DEBUG]: Attempting to remove /var/lib/cloud/instance/boot-finished
2016-09-01 08:09:42,646 - util.py[DEBUG]: Attempting to remove /var/lib/cloud/instance
2016-09-01 08:09:42,647 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2016-09-01 08:09:42,647 - util.py[DEBUG]: Read 10 bytes from /proc/uptime
2016-09-01 08:09:42,647 - util.py[DEBUG]: cloud-init mode 'init' took 0.040 seconds (0.04)
2016-09-01 08:09:44,288 - util.py[DEBUG]: Cloud-init v. 0.7.5 running 'init' at Thu, 01 Sep 2016 12:09:44 +0000. Up 4.24 seconds.
2016-09-01 08:09:44,289 - util.py[DEBUG]: Writing to /var/log/cloud-init.log - ab: [420] 0 bytes
2016-09-01 08:09:44,292 - util.py[DEBUG]: Changing the ownership of /var/log/cloud-init.log to 101:4
2016-09-01 08:09:44,292 - util.py[DEBUG]: Running command ['ifconfig', '-a'] with allowed return codes [0] (shell=False, capture=True)
2016-09-01 08:09:44,297 - util.py[DEBUG]: Running command ['netstat', '-rn'] with allowed return codes [0] (shell=False, capture=True)
2016-09-01 08:09:44,302 - cloud-init[DEBUG]: Checking to see if files that we need already exist from a previous run that would allow us to stop early.
2016-09-01 08:09:44,303 - util.py[DEBUG]: Reading from /var/lib/cloud/data/no-net (quiet=False)
2016-09-01 08:09:44,303 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2016-09-01 08:09:44,303 - util.py[DEBUG]: Reading from /var/lib/cloud/instance/obj.pkl (quiet=False)
2016-09-01 08:09:44,303 - importer.py[DEBUG]: Looking for modules ['ubuntu', 'cloudinit.distros.ubuntu'] that have attributes ['Distro']
2016-09-01 08:09:44,304 - importer.py[DEBUG]: Failed at attempted import of 'ubuntu' due to: No module named ubuntu
2016-09-01 08:09:44,307 - importer.py[DEBUG]: Found ubuntu with attributes ['Distro'] in ['cloudinit.distros.ubuntu']
2016-09-01 08:09:44,307 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.ubuntu.Distro'>
2016-09-01 08:09:44,307 - __init__.py[DEBUG]: Looking for for data source in: ['ConfigDrive'], via packages ['', 'cloudinit.sources'] that matches dependencies ['FILESYSTEM', 'NETWORK']
...

But the boot log complains about this:

Can not apply stage config, no datasource found! Likely bad things to come!
 * Stopping System V initialisation compatibilityESC[94G[ OK ]
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/bin/c...

Read more...

Changed in cloud-init:
status: Incomplete → New
Revision history for this message
Scott Moser (smoser) wrote :

Hi, can you post an entire cloud-init.log ?
Something else is goign wrong.

Generally, what happens is that a datasource is found in cloud-init-local or cloud-init. and then the config and final stages just re-use the found datasource. They dont actually go searching themselves.

Revision history for this message
Joshua Powers (powersj) wrote :

Marking incomplete, pending any further updates from the reporter. If you could provide the logs requested in #3 that would be helpful.

Changed in cloud-init:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for cloud-init because there has been no activity for 60 days.]

Changed in cloud-init:
status: Incomplete → Expired
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.