[2.0rc3] lxd containers do not autostart
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
High
|
Nate Finch |
Bug Description
LXD containers are not autostarting, because the code is setting user.boot.autostart instead of boot.autostart
There are quite a few things interacting here that make this non obvious and hard to test
- LXD containers autostart if they were last running.. running "poweroff" within the LXD host will save that state. Hard powering down the LXD host will not, e.g. echo b > /proc/sysrq-trigger -- in my test environment running poweroff on the host, or pressing it's power button, caused similar unclean shutdowns. This LXD behavior probably needs improving but is separate to the main issue here.
- the key misunderstanding appears to be that Metadata passed to lxdclient.
- there is also code in provider/
Relevant code in container/
metadata := map[string]string{
// An extra piece of info to let people figure out where this
// thing came from.
// Make sure these come back up on host reboot.
}
If we look at a deployed host, we'll see that both juju-model and boot.autostart are set under user:
root@maas-
user.
user.user-data: |
users:
user.
root@maas-
user.
root@maas-
default
docker
root@maas-
name: default
config: {}
description: Default LXD profile
devices:
eth0:
name: eth0
nictype: bridged
parent: lxdbr0
type: nic
Steps to reproduce (tested on rc3, xenial)
- Setup a virtual MAAS with 2 nodes, register it and the credentials in juju
- juju bootstrap maas maas
- juju add-machine
- juju deploy apache2 --to lxd:0
- (wait for deployment)
- juju ssh 0 sudo reboot
- (once restarted) juju ssh 0 sudo lxc list # observe lxc container is running
- juju ssh 0 "echo b | sudo tee /proc/sysrq-
- (once restarted) juju ssh 0 sudo lxc list # observe lxc container is not running
- (optional) juju ssh 0 sudo reboot # observe still not running, because it was not last saved as running
- juju ssh 0 sudo lxc list
- juju ssh 0 sudo lxc config show <instance id> |grep user
Suggested Solution:
I wanted to contribute a patch, but I'm not really sure on the most correct fix. There is no mechanism to pass config into the lxd client right now, so we could either
- Hardcode boot.autostart into lxdclient (seems like a bad idea)
- Convert metadata to config, and explicitly namespace the user parts
- Add an extra mechanism to pass config, separate to metadata
- Investigate when/why the profile is not created in the newEnviron() code and later used to set autostart instead -- then use profiles to set this config
While fixing this, I would also suggest fixing "user.juju-model", as this currently sets user.user.
summary: |
- lxd containers do not autostart + [2.0rc3] lxd containers do not autostart |
Changed in juju: | |
status: | New → Triaged |
importance: | Undecided → Critical |
milestone: | none → 2.0.0 |
tags: | added: rteam |
Changed in juju: | |
milestone: | 2.0.0 → 2.0.1 |
Changed in juju: | |
assignee: | nobody → Richard Harding (rharding) |
Changed in juju: | |
assignee: | Richard Harding (rharding) → nobody |
Changed in juju: | |
assignee: | nobody → Richard Harding (rharding) |
milestone: | 2.0.1 → 2.1.0 |
Changed in juju: | |
assignee: | Richard Harding (rharding) → Mick Gregg (macgreagoir) |
Changed in juju: | |
assignee: | Mick Gregg (macgreagoir) → nobody |
assignee: | nobody → Michael Foord (mfoord) |
Changed in juju: | |
status: | Triaged → In Progress |
Changed in juju: | |
importance: | Critical → High |
tags: | added: eda |
Changed in juju: | |
status: | In Progress → Fix Committed |
milestone: | 2.1.0 → 2.2.0-alpha1 |
Changed in juju: | |
status: | Fix Committed → Fix Released |
Created related lxd bug, about the autostart behavior being confusing: /github. com/lxc/ lxd/issues/ 2469
https:/