-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
@@ -1970,6 +2003,9 @@ sub Configure | |||
# main network config | |||
return if ! defined($self->mk_bu($NETWORKCFG)); | |||
|
|||
# is NetworkManager is allowed?, false by default |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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};
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 totrue
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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" ) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)]); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Dropping this mess in favor of a better solution as suggested in #1586 |
Justification:
chkconfig
and the legacynetwork
service have been deprecated.nmcli
/ip
commands to start and stop the network interfaces if the legacyifup
/ifdown
scripts aren't installed.Incompatibilities:
Acknowledgment: