[lxc-devel] [PATCH 3/4] lxc-ls: Add workaround for nested containers

Stéphane Graber stgraber at ubuntu.com
Thu Dec 19 17:17:31 UTC 2013


On Thu, Dec 19, 2013 at 11:08:53AM -0600, Serge Hallyn wrote:
> Quoting Serge Hallyn (serge.hallyn at ubuntu.com):
> > Quoting Stéphane Graber (stgraber at ubuntu.com):
> > > When accessing nested containers, hardcode the path to their config.
> > > 
> > > Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
> > 
> > Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
> 
> (So actually I meant to pull out the ack)
> 
> > 
> > but,
> > 
> > > ---
> > >  src/lxc/lxc-ls | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/src/lxc/lxc-ls b/src/lxc/lxc-ls
> > > index e358525..d63d9d6 100755
> > > --- a/src/lxc/lxc-ls
> > > +++ b/src/lxc/lxc-ls
> > > @@ -211,6 +211,9 @@ for container_name in lxc.list_containers(config_path=lxcpath):
> > >  
> > 
> > It might be nicer if 'lxcpath' were called 'nested_lxcpath' or
> > something to make it clear how it differs from args.lxcpath.
> > 
> > >      container = lxc.Container(container_name, args.lxcpath)
> > 
> > If container_name exists in args.lxcpath, that configuration file
> > will be loaded right now.
> > 
> > >  
> > > +    if 'NESTED' in os.environ:
> > > +        container.load_config(os.path.join(lxcpath, container_name, "config"))
> > 
> > It doesn't look like the python load_config() function clears the
> > configuration if already loaded - and even if it did it seems a
> > waste to do this.  Why not just
> > 
> >     if 'NESTED' in os.environ:
> >         container = lxc.Container(container_name, lxcpath)
> >     else
> >         container = lxc.Container(container_name, args.lxcpath)
> > 
> > ?

I tried that, but it's failing due to /run/lxc/... not existing in the
host (for obvious reason), which is why I went with that workaround
instead.

However your comments above are right. I'll send an updated patch which
renames the variable and calls clear_config() before the load_config(),
that should take care of your concerns.

> > 
> > >      if container.controllable:
> > >          state = container.state
> > >      else:
> > > -- 
> > > 1.8.5.2
> > > 
> > > _______________________________________________
> > > lxc-devel mailing list
> > > lxc-devel at lists.linuxcontainers.org
> > > http://lists.linuxcontainers.org/listinfo/lxc-devel
> > _______________________________________________
> > lxc-devel mailing list
> > lxc-devel at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-devel
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
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/20131219/6f395ee1/attachment.pgp>


More information about the lxc-devel mailing list