[lxc-devel] Rethinking lxc-info a bit

Stéphane Graber stgraber at ubuntu.com
Wed Nov 13 19:41:55 UTC 2013


Hello,

We recently got reports of the recent changes to lxc-info breaking
existing scripts.

While discusing those issues, I noticed a few points that I think are
worth discussing and addressing, I'm going to postpone alpha3 until
that's done as the current state of things would break quite a bunch of
scripts.

== confusing -n behaviour ==
Since Dwight's last change, -n now accepts a regular expression, which I
believe is the only case where it does. That seems fairly unintuitive
and redundant with what lxc-list for example provides.
This also brought on the next problem.

== change of behaviour when one of the filter is passed ==
In the past, someone could do "lxc-info -n p1 -p" and trivially retrieve
the PID.

The new behaviour instead returns:
Name:           p1
Pid:            19446

Even though I didn't ask for the container's name. "pid" was also
renamed to "Pid", breaking anyone attempting to grep for the entry.

== --state-is option is redundant ==
The state-is option always seemed a bit odd to me, in fact, it's
absolutely identical to "lxc-wait -t 0 -n <name> -s <STATE>" and I don't
really think it has its place in lxc-info. I'd suggest we just remove it
entirely (yes, that'll break some scripts).


I'm sorry I didn't think about those problems when reviewing the recent
changes to lxc-info, but hopefully it's not too late to correct some of
that.


So my suggestion for lxc-info in LXC 1.0 are:
 - Only support one container and make -n mandatory, fail with an error
   if the container can't be found.
 - Drop --state-is entirely and tell anyone who used it to use lxc-wait
   instead.
 - Only print Name: if none of the filters are passed
 - Make the combination of -H + a single filter only return that value,
   so that "lxc-info -n p1 -P -H" will just return 19446 without any
   formatting. Recommend doing that to anyone parsing lxc-info's output.
 - Have -H also apply to the general formatting, simply printing <key>:
   <value> when passed.


With those done, there will still be breakage for users of alpha2
upgrading to alpha3, but that should at least ensure no more surprises
after that point and a more script friendly command.


Thoughts?

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131113/db9c89ad/attachment.pgp>


More information about the lxc-devel mailing list