vip-manager icon indicating copy to clipboard operation
vip-manager copied to clipboard

Fix get_dev in namespaced environments

Open df7cb opened this issue 3 years ago • 5 comments

Commit cd9ab2911952ac42 fixed device selection in environments that have multiple devices, but unfortunately broke it on apt.postgresql.org, where the tests are running in network namespaces via veth/ceth devices. This fixes the detection to support both.

df7cb avatar Aug 25 '22 15:08 df7cb

The problem here was that /sys/class/net/* lists all the devices from the host system, but inside the network namespace, only one is present (and moreover, it has the wrong end of the ceth/veth pair). "ip link" has the correct list.

df7cb avatar Aug 26 '22 07:08 df7cb

Hmm, true. On my laptop, the first one returns eth0, while the new one returns

 eth0
 wlan2
 veth1

We should probably just append | head -n1 to the new version since that one actually fixes a problem on apt.postgresql.org.

df7cb avatar Sep 15 '22 18:09 df7cb

Hi @df7cb

Hmm, true. On my laptop, the first one returns eth0, while the new one returns

 eth0
 wlan2
 veth1

We should probably just append | head -n1 to the new version since that one actually fixes a problem on apt.postgresql.org.

Is it guaranteed, that ip -oneline link show outputs the Ethernet interfaces first? As before: I'm not sure my critique is relevant, since I haven't checked in which context this code gets used. I just know that network interface naming in modern Linux systems is quite incomprehensible to me so I wouln't be suprised at all, if udev or whoever is responsible for naming would name the Ethernet interface zaziki99 and the WLAN interface aleph1 and thereby possibly returning the WLAN interface first in the list...

But as I said, no idea if my criticism is relevant. I'm just observing that the code before and after do not behave in the same way.

tpo avatar Sep 16 '22 08:09 tpo

I don't know about any ordering constraints, but I'd say the old for dev in /sys/class/net/* code didn't care about that either, so it won't change the quality of the result.

df7cb avatar Sep 16 '22 17:09 df7cb

Is it guaranteed, that ip -oneline link show outputs the Ethernet interfaces first? As before: I'm not sure my critique is relevant, since I haven't checked in which context this code gets used. I just know that network interface naming in modern Linux systems is quite incomprehensible to me so I wouln't be suprised at all, if udev or whoever is responsible for naming would name the Ethernet interface zaziki99 and the WLAN interface aleph1 and thereby possibly returning the WLAN interface first in the list...

WLAN interfaces are ether as well, so that wouldn't make a difference. From what I can tell, all that's relevant here is that we find an interface that has an IP that can be used for testing.

df7cb avatar Sep 17 '22 09:09 df7cb

hey there. Sorry for such a delay. Tough time, eh.

So is this PR still valid and should be applied?

Best regards

pashagolub avatar Oct 17 '22 14:10 pashagolub

Hi Pavlo, yes it still fixes the test problems we've had with vip-manager on apt.postgresql.org. Christoph

df7cb avatar Oct 17 '22 14:10 df7cb

Thanks Christoph!

Merged! 👍

pashagolub avatar Oct 17 '22 14:10 pashagolub

Thanks!

df7cb avatar Oct 17 '22 14:10 df7cb

Speaking of apt.postgresql.org...

@df7cb are you using scripts/files from package folder or do you have your own?

The reason is I want to establish GHA workflow for automatic packaging/building and want to know if I'm allowed make some changes to those files.

We are preparing the v2-beta with some breaking changes and I'm trying to figure out what exactly I can drop/change but to leave everybody happy

pashagolub avatar Oct 17 '22 14:10 pashagolub

The packaging files are there: https://salsa.debian.org/postgresql/vip-manager/-/tree/master/debian

We are not using anything from the package except for what gets invoked by the normal build system, i.e. what gets invoked by dh $@ --buildsystem=golang --with=golang: https://salsa.debian.org/postgresql/vip-manager/-/blob/master/debian/rules

df7cb avatar Oct 17 '22 14:10 df7cb