[lxc-users] sticky ethernet device order in container

Serge Hallyn serge.hallyn at ubuntu.com
Fri Jun 5 22:59:37 UTC 2015


Quoting S.Çağlar Onur (caglar at 10ur.org):
> Hey Serge,
> 
> On Fri, Jun 5, 2015 at 12:29 AM Serge Hallyn <serge.hallyn at ubuntu.com>
> wrote:
> 
> > What i described was in lxc (i.e. lxc-start), not lxd (i.e. lxc launch).
> >
> > In lxd, if my understanding of how golang handles map range is correct,
> > then devices coming from a profile should be applied first (in the order
> > in which profiles were applied), then container-specific ones.
> >
> 
> Go's map iteration order (using the range keyword) is random, could that be
> the source of this problem?

Yup.  My little custom test always split out entries in the order in which
I'd inserted them, but I realized that was not reliable or certainly wouldn't
stay so, so I did open an issue for this.

If someone wants to hack on https://github.com/lxc/lxd/issues/734 that'd
be great :)  Shouldn't be a big deal - set the order as we add devices to
the lxdContainer in newLxdContainer, and enforce the order in applyDevices.

> > Quoting Janjaap Bos (janjaapbos at gmail.com):
> > > They are on different bridges. The config only has the additional nic,
> > > which should be eth1, and usually is.
> > > The eth0 nic is defined in the default profile, which is referred to in
> > the
> > > config.
> > >
> > > I will test further, just to rule out confusion at my side. It is good to
> > > know that the order should be as in the config. Maybe it is related to
> > > applying the profile to the config.
> > >
> > >
> > > 2015-06-04 17:26 GMT+02:00 Serge Hallyn <serge.hallyn at ubuntu.com>:
> > >
> > > > Quoting Janjaap Bos (janjaapbos at gmail.com):
> > > > > When using multiple nics in the container, the order sometimes
> > changes
> > > > > after a restart.
> > > > > So eth0 becomes eth1, vice versa.
> > > >
> > > > That really shouldn't happen.  lxc adds the nics in a specific order
> > > > (according to the config).  Are eth0 and eth1 on different bridges?
> > > > Or perhaps I should ask - how do you determine that they've "switched
> > > > order"?
> > > >
> > > > > when using LXD, how is this order determined?
> > > > > There is no entry for eth0 in the config, since that is a standard
> > lxc
> > > > > network device.
> > > > > Only the additional network device is added in the container config:
> > > > > e.g.
> > > > >
> > > > > name: c1
> > > > > profiles:
> > > > > - default
> > > > > config:
> > > > >   raw.lxc: |
> > > > >     lxc.mount.entry = /var/lib/lxd/lxc/c1/devices/net/tun dev/net/tun
> > > > none
> > > > > bind,create=file 0 0
> > > > >     lxc.mount.entry = /var/lib/lxd/lxc/c1devices/kvm dev/kvm none
> > > > > bind,create=file 0 0
> > > > >     lxc.mount.entry = /var/lib/lxd/lxc/c1/devices/fuse dev/fuse none
> > > > > bind,create=file 0 0
> > > > >   volatile.baseImage:
> > > > > a4066a730e6b3d8021dcc7d0c59f2c37624ffdb60d10f1e09c336e4e1631915c
> > > > >   volatile.eth0.hwaddr: 00:16:3e:33:3c:c2
> > > > >   volatile.br0.hwaddr: 00:16:3e:5b:4f:19
> > > > > devices:
> > > > >   br0:
> > > > >     parent: br0
> > > > >     type: nic
> > > > > ephemeral: false
> > > > >
> > > > >
> > > > > Both nics have a volatile entry (done by lxc or lxd ?)
> > > > >
> > > > > Sometime after a restart the nics have switched order in the
> > container.
> > > > > This of course messes up the network config in the container.
> > > > >
> > > > > How can I make the eth0 and eth1 order stick?
> > > > >
> > > > > Thanks for your help!
> > > > >
> > > > > -Janjaap
> > > >
> > > > > _______________________________________________
> > > > > lxc-users mailing list
> > > > > lxc-users at lists.linuxcontainers.org
> > > > > http://lists.linuxcontainers.org/listinfo/lxc-users
> > > >
> > > > _______________________________________________
> > > > lxc-users mailing list
> > > > lxc-users at lists.linuxcontainers.org
> > > > http://lists.linuxcontainers.org/listinfo/lxc-users
> >
> > > _______________________________________________
> > > lxc-users mailing list
> > > lxc-users at lists.linuxcontainers.org
> > > http://lists.linuxcontainers.org/listinfo/lxc-users
> >
> > _______________________________________________
> > lxc-users mailing list
> > lxc-users at lists.linuxcontainers.org
> > http://lists.linuxcontainers.org/listinfo/lxc-users

> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users



More information about the lxc-users mailing list