Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 517144 - app-emulation/lxc-1.0.4 – lxc-info may print nothing, confusing the init script
Summary: app-emulation/lxc-1.0.4 – lxc-info may print nothing, confusing the init script
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Diego Elio Pettenò (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-15 10:09 UTC by Dennis Schridde
Modified: 2014-10-18 16:24 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Schridde 2014-07-15 10:09:42 UTC
After updating from LXC 0.8.0 to 1.0.4, lxc-info does not print anything for my containers. This in turn confuses the init script, which relies on lxc-info having an output for non-running containers. The result are non-descriptive error messages.

Reproducible: Always
Comment 1 Markos Chandras (RETIRED) gentoo-dev 2014-07-20 10:35:35 UTC
Please provide more information for example:

your emerge --info

emerge -pv lxc

lxc-info works for me.
Comment 2 Dennis Schridde 2014-07-22 06:17:57 UTC
On my ia64 machine, which I booted while having LXC 0.8 installed and later updated to 1.0, lxc-info does not generate any output. Apparently it is unable to find the init PID of the containers.

So there exists a codepath in lxc-info, which does not produce any output (even if only due to internal errors), so I think that Gentoo's init script should consider this case, especially as the fix is a simple `if [[ "${init_pid}" ]] ; then … fi`, just as for the pid=-1 case.
Comment 3 Markos Chandras (RETIRED) gentoo-dev 2014-07-22 17:06:14 UTC
(In reply to Dennis Schridde from comment #2)
> On my ia64 machine, which I booted while having LXC 0.8 installed and later
> updated to 1.0, lxc-info does not generate any output. Apparently it is
> unable to find the init PID of the containers.
> 
> So there exists a codepath in lxc-info, which does not produce any output
> (even if only due to internal errors), so I think that Gentoo's init script
> should consider this case, especially as the fix is a simple `if [[
> "${init_pid}" ]] ; then … fi`, just as for the pid=-1 case.

you are right it does not print anything if the container is stopped
Comment 4 Markos Chandras (RETIRED) gentoo-dev 2014-07-22 18:17:22 UTC
(In reply to Markos Chandras from comment #3)
> (In reply to Dennis Schridde from comment #2)
> > On my ia64 machine, which I booted while having LXC 0.8 installed and later
> > updated to 1.0, lxc-info does not generate any output. Apparently it is
> > unable to find the init PID of the containers.
> > 
> > So there exists a codepath in lxc-info, which does not produce any output
> > (even if only due to internal errors), so I think that Gentoo's init script
> > should consider this case, especially as the fix is a simple `if [[
> > "${init_pid}" ]] ; then … fi`, just as for the pid=-1 case.
> 
> you are right it does not print anything if the container is stopped

Does this fix your problem?

--- lxc.initd.2	2012-11-14 02:15:10.000000000 +0000
+++ lxc.initd.3	2014-07-22 19:16:10.707705009 +0100
@@ -106,7 +106,7 @@
 
 	init_pid=$(lxc-info -n ${CONTAINER} --pid | awk '{ print $2 }')
 
-	if [ "${init_pid}" = "-1" ]; then
+	if [ -z "${init_pid}" ]; then
 	    ewarn "${CONTAINER} doesn't seem to be running."
 	    return 0
 	fi
Comment 5 Dennis Schridde 2014-07-22 18:44:28 UTC
That is almost the patch I used, so I am sure: Yes, it will.

I think that a change from outputting -1 to having a different exit code for lxc-info was also documented somewhere, but I could not find it anymore when reporting this issue.
Comment 6 Markos Chandras (RETIRED) gentoo-dev 2014-07-22 18:48:49 UTC
(In reply to Dennis Schridde from comment #5)
> That is almost the patch I used, so I am sure: Yes, it will.
> 
> I think that a change from outputting -1 to having a different exit code for
> lxc-info was also documented somewhere, but I could not find it anymore when
> reporting this issue.

If you find it useful to return a different exit code when the container is not running I suppose we can 'return 1' in the init script. Though this will break existing scripts which expect the init script to always return 0 if the container is not running so I'd rather not change this behavior.

There is another python3 related fix I need to sort out before I revbump so this bug may take a while to be marked as resolved.
Comment 7 Dennis Schridde 2014-07-23 00:24:56 UTC
(In reply to Markos Chandras from comment #6)
> (In reply to Dennis Schridde from comment #5)
> > That is almost the patch I used, so I am sure: Yes, it will.
> > 
> > I think that a change from outputting -1 to having a different exit code for
> > lxc-info was also documented somewhere, but I could not find it anymore when
> > reporting this issue.
> 
> If you find it useful to return a different exit code when the container is
> not running I suppose we can 'return 1' in the init script. Though this will
> break existing scripts which expect the init script to always return 0 if
> the container is not running so I'd rather not change this behavior.

What I meant was: I *think* in a release announcement or similiar half a year ago I read something about the behaviour of lxc-info being changed in LXC 1.0 when the container is not running. This would officially confirm that your patch is correct. Sadly I cannot find that text anymore.
Comment 8 Markos Chandras (RETIRED) gentoo-dev 2014-10-18 16:24:40 UTC
This is already fixed