Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[-] dix get_dev in namespaced environments #98

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

df7cb
Copy link
Member

@df7cb df7cb commented Aug 25, 2022

Commit cd9ab29 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.

Commit cd9ab29 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
Copy link
Member Author

df7cb commented Aug 26, 2022

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.

Copy link
Contributor

@tpo tpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my laptop:

$ cat pre 
ARPHRD_ETHER=1

    for dev in /sys/class/net/* ; do
        test ! -e "$dev/address" && continue
        test "`cat $dev/address`" = "00:00:00:00:00:00" && continue
        test "`cat $dev/type`" != "$ARPHRD_ETHER" && continue
        basename "$dev"
        break
    done

$ cat post  
ip -oneline link show | grep link/ether | grep -v 00:00:00:00:00:00 | cut -d ":" -f2 | cut -d "@" -f 1

$ source pre
docker0

$ source post
 wlo1
 docker0

So the new version of the code does not strictly behave like the old code: it does not check the network type.

Is that relevant?

@df7cb
Copy link
Member Author

df7cb commented Sep 15, 2022

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.

@tpo
Copy link
Contributor

tpo commented Sep 16, 2022

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.

@df7cb
Copy link
Member Author

df7cb commented Sep 16, 2022

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
Copy link
Member Author

df7cb commented Sep 17, 2022

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.

@pashagolub
Copy link
Collaborator

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

So is this PR still valid and should be applied?

Best regards

@df7cb
Copy link
Member Author

df7cb commented Oct 17, 2022

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

@pashagolub
Copy link
Collaborator

Thanks Christoph!

Merged! 👍

@pashagolub pashagolub changed the title Fix get_dev in namespaced environments [-] dix get_dev in namespaced environments Oct 17, 2022
@pashagolub pashagolub merged commit 507949d into cybertec-postgresql:master Oct 17, 2022
@df7cb
Copy link
Member Author

df7cb commented Oct 17, 2022

Thanks!

@pashagolub
Copy link
Collaborator

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

@df7cb
Copy link
Member Author

df7cb commented Oct 17, 2022

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 df7cb deleted the ip-link branch October 17, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants