Comment 28 for bug 1582323

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

$ name="$release-test"
$ lxc init ubuntu-daily:$release $name

# change pid 1's command line, which is used by cloud-init
# instead of kernel command line inside a container.
$ cmdline="cc:{'datasource_list': ['MAAS']}end_cc"
$ lxc config set $name raw.lxc "lxc.init_cmd=/sbin/init $cmdline"

$ lxc start $name
# sleep
$ sleep 10

## show info about instance
$ lxc exec $name -- dpkg-query --show cloud-init
cloud-init 0.7.8-68-gca3ae67-0ubuntu1~16.10.1

# pid1 has the cmdline shown
$ lxc exec $name -- cat /proc/1/cmdline; echo
/sbin/initcc:{'datasource_list':['MAAS']}end_cc

$ lxc exec $name -- cat /run/cloud-init/result.json
{
 "v1": {
  "datasource": "DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]",
  "errors": []
 }
}

$ lxc file pull $name/etc/cloud/build.info -
build_name: server
serial: 20170207

## enable proposed, update
$ m=http://archive.ubuntu.com/ubuntu;
$ echo "deb $m $release-proposed main" | lxc file push - $name/etc/apt/sources.list.d/proposed.list
$ lxc exec $name -- sh -c 'apt-get update -q && apt-get install cloud-init' </dev/null
$ lxc exec $name -- dpkg-query --show cloud-init
cloud-init 0.7.9-0ubuntu1~16.10.1

# clean up to make it look like first boot.
$ lxc exec $name -- sh -c 'cd /var/lib/cloud; for d in *; do [ "$d" = "seed" ] || rm -vRf "$d"; done'
$ lxc exec $name -- sh -c 'rm -f /var/log/cloud*'
$ lxc restart $name
$ sleep 10

$ lxc exec $name -- cat /run/cloud-init/result.json
{
 "v1": {
  "datasource": null,
  "errors": [
   "No instance datasource found.",
   "Can not apply stage config, no datasource found! Likely bad things to come!",
   "Can not apply stage final, no datasource found! Likely bad things to come!"
  ]
 }
}

$ lxc exec $name -- grep -i "Searching for" /var/log/cloud-init.log
2017-02-10 14:57:42,046 - __init__.py[DEBUG]: Searching for local data source in: []
2017-02-10 14:57:42,074 - handlers.py[DEBUG]: finish: init-local: SUCCESS: searching for local datasources
2017-02-10 14:57:43,805 - __init__.py[DEBUG]: Searching for network data source in: ['DataSourceMAAS']
2017-02-10 14:57:43,805 - handlers.py[DEBUG]: start: init-network/search-MAAS: searching for network data from DataSourceMAAS
2017-02-10 14:57:43,832 - handlers.py[DEBUG]: finish: init-network: SUCCESS: searching for network datasources