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

Add network flushing before setting up network #58

Merged
merged 1 commit into from Jan 13, 2022

Conversation

sergio-correia
Copy link
Member

This should allow for using the nbde_client role with machines that use
static IP configurations, as network flushing should undo the network
setup done at the initramfs, allowing the system to use its regular
configuration.

Approach based on the answers posted here:
https://unix.stackexchange.com/questions/506331/networkmanager-doesnt-change-ip-address-when-dracut-cmdline-provided-static-ip/541108

@@ -0,0 +1,8 @@
#!/bin/sh

for iface in $(ip link | sed -rn 's@^[0-9]+:\s+([[:alnum:]]+):.*@\1@p'); do
Copy link
Contributor

Choose a reason for hiding this comment

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

@tyll is there a better way to do this?

Copy link
Member

Choose a reason for hiding this comment

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

you mean to get a list of all interfaces?

ip -oneline link show can make the sed expression easier or you can use cut and remove the leading whitespace. There is also -brief so ip -oneline -brief link show | cut -d" " -f 1 can be an option, too. Technically, interface names can use any encoding and character, so this is all not 100% correct. ip -json -brief can create json output that might handle this best but would need a more complex script to handle it.

Each interface is also a symlink in /sys/class/net/, so you can also get the interface names like this:

for f in /sys/class/net/*; do echo ${f##*/}; done

@thom311 any suggestions/comments?

Copy link

Choose a reason for hiding this comment

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

JSON output of iproute2 would be nicer. But on some systems, that's not available (in particular, CentOS7).

From sysfs might be good. Note there are some special files there like bonding_masters. Guess you could do something like (cd /sys/class/net/; for f in */; do echo ${f%/}; done) to get rid of that.

but I have no strong preference here.

Sergio, did you strip interfaces with a parent, like vethf6a43f04@if9, on purpose?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sergio, did you strip interfaces with a parent, like vethf6a43f04@if9, on purpose?

It was probably accidental. I initially was using nmcli -t device, which was simpler to use the output with cut, but I think I had issues with CentOS 7, then I switched to this other approach. I like your suggestion (and tyll's) of using /sys/class/net/, so I will change to use it instead. Thanks!

@richm
Copy link
Contributor

richm commented Jan 8, 2022

[citest bad]

@richm
Copy link
Contributor

richm commented Jan 8, 2022

@sergio-correia how do we test this? Can we have an automated test for this?

@richm
Copy link
Contributor

richm commented Jan 10, 2022

[citest bad]

@sergio-correia
Copy link
Member Author

@sergio-correia how do we test this? Can we have an automated test for this?

One way to to test this would be to configure a system set up with a LUKS-encrypted device and a static IP address. We can then use the ansible role and once the machine does the automated unlocked, after a reboot, we can inspect that it still has the same static IP that it was configured before.

it's not impossible to have an automated test for this, but it's not straightforward either. We could easily provision a VM with the required setup with a kickstart file, for instance, but then we need a way to make sure the VM boots properly the first time, without user interaction.

@richm
Copy link
Contributor

richm commented Jan 10, 2022

@sergio-correia how do we test this? Can we have an automated test for this?

One way to to test this would be to configure a system set up with a LUKS-encrypted device and a static IP address. We can then use the ansible role and once the machine does the automated unlocked, after a reboot, we can inspect that it still has the same static IP that it was configured before.

Do we need a separate nbde server machine to test this? If so, then we can't have an automated test for this, at least with our current test framework. Then assuming we can't have an automated test for this, what is the QE procedure to verify this change?

it's not impossible to have an automated test for this, but it's not straightforward either. We could easily provision a VM with the required setup with a kickstart file, for instance, but then we need a way to make sure the VM boots properly the first time, without user interaction.

@sergio-correia
Copy link
Member Author

Do we need a separate nbde server machine to test this? If so, then we can't have an automated test for this, at least with our current test framework. Then assuming we can't have an automated test for this, what is the QE procedure to verify this change?

Yes, the nbde server machine cannot be the same one as the client, as the client will attempt to communicate with it while booting. If using virtualization, we could run the server on the host, whlie the guest would run the client.

As for the QE procedure to verify this, I am not 100% sure, but I suspect it would be a manual test doing what I suggested in the previous message: setting up a machine with LUKS and static IP and using the nbde_client role + a reboot to verify things worked as expected.

@richm
Copy link
Contributor

richm commented Jan 11, 2022

lgtm - but first you will need to rebase on top of the latest master code - this changes the way the role is symlinked under tests/roles/linux-system-roles.nbde_client - you will need to add symlinks there for files and templates

tasks/main-clevis.yml Outdated Show resolved Hide resolved
This should allow for using the nbde_client role with machines that use
static IP configurations, as network flushing should undo the network
setup done at the initramfs, allowing the system to use its regular
configuration.

Approach based on the answers posted here:
https://unix.stackexchange.com/questions/506331/networkmanager-doesnt-change-ip-address-when-dracut-cmdline-provided-static-ip/541108
@sergio-correia
Copy link
Member Author

@richm: I have rebased it and added the symlinks.

@richm
Copy link
Contributor

richm commented Jan 12, 2022

@richm: I have rebased it and added the symlinks.

Thanks! I'm monitoring the test runs - if they look good I'll merge

@richm
Copy link
Contributor

richm commented Jan 12, 2022

[citest]

@sergio-correia
Copy link
Member Author

@richm: what is the 2.9 version we use in those CentOS-7-latest/ansible-2.9/(citool) and RHEL-7.9-20200917.0/ansible-2.9/(citool) tests that failed?

@richm
Copy link
Contributor

richm commented Jan 13, 2022

@richm: what is the 2.9 version we use in those CentOS-7-latest/ansible-2.9/(citool) and RHEL-7.9-20200917.0/ansible-2.9/(citool) tests that failed?

Don't worry about those failures - they are unrelated - the CI team is working on it.

@richm richm merged commit 017e2d8 into linux-system-roles:master Jan 13, 2022
@sergio-correia sergio-correia deleted the network_flush branch March 29, 2022 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants