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

ncm-network: allow NetworkManager configuration for EL9 compatibility #1585

Closed
wants to merge 2 commits into from

Conversation

victor-mendoza
Copy link
Contributor

Justification:

  • allow configuration through NetworkManager on EL9 where chkconfig and the legacy network service have been deprecated.
  • use nmcli/ip commands to start and stop the network interfaces if the legacy ifup/ifdown scripts aren't installed.

Incompatibilities:

  • none: legacy binaries, scripts and behavior are prioritized.

Acknowledgment:

@@ -1970,6 +2003,9 @@ sub Configure
# main network config
return if ! defined($self->mk_bu($NETWORKCFG));

# is NetworkManager is allowed?, false by default
Copy link
Member

Choose a reason for hiding this comment

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

it's not false by default, because you have defined(allow_nm) in all the logic above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

allow_nm was already part of the schema, one must explicitly define it as true in the profile otherwise it will be set to false by : my $allow_nm = $nwtree->{allow_nm};.

Copy link
Member

Choose a reason for hiding this comment

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

ok, but then you don't need the defined() tests in this code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll remove them

if (!$self->_is_executable($CHKCONFIG_CMD) && defined($allow_nm) && $allow_nm) {
$service_name = "NetworkManager";
} else {
$self->error("chkconfig unavailable, NetworkManager not allowed");
Copy link
Member

Choose a reason for hiding this comment

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

what does chkconfig have to do with NetworkManager?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nothing, if chkconfig isn't found (as is the case on EL9), it will fallback to NetworkManager, if allow_nm is set to true in the profile.

Copy link
Member

Choose a reason for hiding this comment

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

chkconfig can still be present because of other tools on the system that need it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case I'll try adding a new schema entry to unambiguously choose the desired network service, and stop checking for the presence of chkconfig.

Copy link
Contributor

Choose a reason for hiding this comment

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

nothing, if chkconfig isn't found (as is the case on EL9), it will fallback to NetworkManager, if allow_nm is set to true in the profile.

chkconfig is found in rhel9, what fails is "chkconfig --level 2345 network on", as there is no service Network on rhel9. on our rhel9 build we have to use chkconfig for other services (legacy), so this code will fail.

@@ -1562,9 +1590,14 @@ sub start
} elsif (@ifaces) {
my @cmds;
foreach my $iface (@ifaces) {
push(@cmds, ["/sbin/ifup", $iface, "boot"]);
if ($self->_is_executable($IFUP_CMD)) {
Copy link
Member

Choose a reason for hiding this comment

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

this requires the networkmanager compatibility rpm?

Copy link
Member

Choose a reason for hiding this comment

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

ok, not requires, but does it work when that rpm is present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it will use the legacy ifup/ifdown scripts if they are installed, otherwise it will use nmcli (if allowed)

Copy link
Member

Choose a reason for hiding this comment

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

tbh i would require the ifup/ifdown being present, and not implement your own version of it like the link removal code if ifdown is not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll revert this.

@@ -1481,10 +1489,30 @@ sub stop
if ($nwupdated || @ifaces) {
if (@ifaces) {
my @cmds;
# delete NetworkManager connections
foreach my $file ( glob "/etc/NetworkManager/system-connections/*.nmconnection" ) {
Copy link
Member

Choose a reason for hiding this comment

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

i don't know how networkmanager works, but ncm-network will try it's best to restore previous working network if the component would hit some error.
if these files are required for such recover, you best not delete them; but eg rename and make sure they get restored if needed (and cleaned up when working and really not needed anymore)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any automatically (during install) or manually created files in that path will take precedence, they are deleted so the legacy 'ifcfg' files are used by NetworkManager instead, the backup/recovery will continue to work.

Copy link
Member

Choose a reason for hiding this comment

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

not if this is the initial install, then recovery will be broken without these files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll try to add these files to the recovery instead

# how do we actually know that the device was up?
# eg for non-existing device eth4: /sbin/ifdown eth4 --> usage: ifdown <device name>
push(@cmds, ["/sbin/ifdown", $iface]);
if ($self->_is_executable($IFDOWN_CMD)) {
Copy link
Member

Choose a reason for hiding this comment

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

you asume that ifup is present below, but you check it is missing ifdown?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you lost me, ifup is only used in sub start

push(@cmds, ["ip", "link", "set", $iface, "down"]);
}
} else {
# stop the interface
Copy link
Member

Choose a reason for hiding this comment

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

at the very least log an error here. because this is not permanent removal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you please elaborate? this is just trying to reset the interface to a default state so the new configuration can be applied with a greater chance of success

$self->runrun(@disablenm_cmds);
if ($self->_is_executable($CHKCONFIG_CMD)) {
# TODO: do something smart with 'require NCM::Component::Systemd::...' to turn it off
return $self->runrun([qw(/sbin/chkconfig --level 2345 network off)]);
Copy link
Member

Choose a reason for hiding this comment

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

why do you stop network, while the comments only mention networkmanager
and also, what does this have to do with chkconfig being present

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my mistake, I'll fix this

@victor-mendoza
Copy link
Contributor Author

Dropping this mess in favor of a better solution as suggested in #1586

@victor-mendoza victor-mendoza deleted the network-el9 branch May 12, 2023 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants