Bug 914856

Summary: LXC container no't autostart with systemd
Product: [openSUSE] openSUSE Distribution Reporter: Forgotten User PrwYuMFWze <forgotten_PrwYuMFWze>
Component: OtherAssignee: Thorsten Behrens <thb>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Major    
Priority: P5 - None CC: chcao, forgotten_EDqOSbwq2P, forgotten_PrwYuMFWze, novell, systemd-maintainers
Version: 13.2   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE 13.2   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Config of container

Description Forgotten User PrwYuMFWze 2015-01-27 02:46:45 UTC
Created attachment 620947 [details]
Config of container

LXC container no't autostart with systemd by default.
Config of container in attach.

Autostart star work after editing systemd unit file (/usr/lib/systemd/system/lxc.service):


[Unit]
Description=LXC Container Initialization and Autoboot Code
After=syslog.target network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/usr/lib/lxc/lxc-devsetup

####Comment this 2 strings
#ExecStart=/usr/lib/lxc/lxc-autostart-helper start
#ExecStop=/usr/lib/lxc/lxc-autostart-helper stop

####Add this 2 strings
ExecStart=/usr/bin/lxc-autostart -g onboot
ExecStop=/usr/bin/lxc-autostart -a -s -t 5

StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target
Comment 1 Forgotten User EDqOSbwq2P 2015-03-30 13:26:43 UTC
It is a bug in the lxc-autostart-helper file, called by the lxc.service:

line 109: action $"Starting LXC autoboot containers: " "$bindir"/lxc-autostart $OPTIONS $BOOTGROUPS

action is a self-defined function ... it echos "Starting LXC autoboot container..." , but executes nothing:

my fix:

diff  lxc-autostart-helper.old /usr/lib/lxc/lxc-autostart-helper 
51c51,53
<         echo "$@"
---
> 	echo -n "$1 ..."
> 	shift
>       "$@" && echo " SUCCESS" || echo " FAILED"
Comment 2 Terry Sanders 2015-06-15 12:54:31 UTC
Workaround:

edit/create /etc/sysconfig/lxc and add the following:

action() {
 	echo -n "$1 ..."
 	shift
       "$@" && echo " SUCCESS" || echo " FAILED"
}
Comment 4 Chenzi Cao 2016-02-17 03:25:51 UTC
Hi Jiri, would you please help to have a look at this issue? Please feel free to reassign whenever necessary, thank you!
Comment 5 Jiri Slaby 2016-03-07 13:03:08 UTC
This is a bit old. Does it still happen?
Comment 6 Terry Sanders 2016-03-09 11:19:32 UTC
This is still a problem.

Tested it with lxc-1.0.6-9.1.x86_64

Test procedure

1. systemctl stop lxc.service
2. Removed workaround from /etc/sysconfig/lxc (see comment #2)
3. systemctl start lxc.service
4. lxc-ls -f reveals no containers have started
5. systemctl stop lxc.service
6. re-added workaround
7. systemctl start lxc.service
8. lxc-ls -f reveals all autostart containers are running.
Comment 7 Jiri Slaby 2016-04-18 07:37:14 UTC
I'm no longer in charge of lxc. Perhaps Thorsten can help?
Comment 8 Tomáš Chvátal 2018-04-12 13:59:33 UTC
This version of openSUSE changed to end-of-life (EOL [1]) status. As such
it is no longer maintained, which means that it will not receive any
further security or bug fix updates.
As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
openSUSE, or consider the bug still valid, please feel free to reopen this
bug against that version, or open a new ticket.

Thank you for reporting this bug and we are sorry it could not be fixed
during the lifetime of the release.

[1] https://en.opensuse.org/Lifetime