snapcore / spread

Spread - Convenient full-system test (task) distribution
GNU General Public License v3.0
99 stars 58 forks source link

backends: LXD: don't hardcode eth0 #178

Open thp-canonical opened 6 months ago

thp-canonical commented 6 months ago

With the ubuntu-22.04 image, the network interface seems to be sometimes named "enp5s0" instead of "eth0". To be compatible with both old and new releases, consider any non-loopback interface viable for retrieving an IP address.

bboozzoo commented 5 months ago

ping @ZeyadYasser, please have a look

bboozzoo commented 5 months ago

Unless the configuration adds another interface explicitly, the container will have lo and another non-lo interface (the problem here is that the name was hardcoded), so I suppose we could have a check if there's at most 2 interfaces, or simply only 1 that isn't lo? I'm not sure the connectivity check is necessary, as we did not have one before and the thing will simply fail on the next step trying to connect to the VM. This is exactly what happens without this change.

thp-canonical commented 5 months ago

I suppose we could have a check if there's at most 2 interfaces, or simply only 1 that isn't lo?

I'm assuming here that if multiple non-lo network interfaces are configured, any network interface would work for connecting (the first one that matches and has an IPv4 address), so this isn't strictly incompatible with multiple interfaces.

Spread didn't have the restriction of "only a single non-lo interface" before (it would work just fine with multiple interfaces, as long as there also was eth0), so I didn't want to introduce this additional restriction here.

If there are multiple interfaces where only some of them are suitable for Spread to connect via SSH, we probably need additional configuration anyway (and that is probably outside of the scope of this PR).