mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-12 08:12:33 +00:00
fix(dhcp): load a new ISC configuration before OMAPI changes a host
makedhcp builds a new configuration when dhcpd.conf is missing or xCAT did not write it. It replaced each host over OMAPI before dhcpd loaded that configuration. A dhcpd that still ran an older one then rejected a host that tests an iPXE feature option. OMAPI had already removed the old host, so the node lost its reservation. makedhcp now writes the new configuration and restarts dhcpd first. It changes no host when that restart fails. The restart marker of an upgraded configuration now also covers a new one, so the next run restarts dhcpd first after a run that stopped before the restart.
This commit is contained in:
@@ -2367,11 +2367,23 @@ sub process_request
|
||||
}
|
||||
}
|
||||
|
||||
my $newconf;
|
||||
unless ($dhcpconf[0])
|
||||
{ #populate an empty config with some starter data...
|
||||
$restartdhcp = 1;
|
||||
$newconf = 1;
|
||||
newconfig();
|
||||
}
|
||||
|
||||
# Until dhcpd restarts, it can run without the options of this new configuration: see _isc_declare_ipxe_features.
|
||||
my $pending = "$dhcpconffile.ipxe-restart";
|
||||
if ($newconf and $^O ne 'aix' and not $::XCATSITEVALS{externaldhcpservers}) {
|
||||
my $fh;
|
||||
unless (open($fh, '>', $pending) and close($fh)) {
|
||||
$callback->({ error => ["Unable to write a new configuration to $dhcpconffile: cannot create $pending: $!"], errorcode => [1] });
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($usingipv6 and not $dhcp6conf[0]) {
|
||||
$restartdhcp6 = 1;
|
||||
newconfig6();
|
||||
@@ -2550,6 +2562,21 @@ sub process_request
|
||||
} # TODO sane err
|
||||
($omapi_settings, $omapi_secret) = ($settings, $ent->{password});
|
||||
|
||||
# OMAPI replaces each host on the running dhcpd, so dhcpd first loads the configuration this run built.
|
||||
if ($newconf and @{ $req->{node} } and not $::XCATSITEVALS{externaldhcpservers}) {
|
||||
# writeout() empties the configuration in memory, which the final writeout() still needs.
|
||||
my @conf = @dhcpconf;
|
||||
my @conf6 = @dhcp6conf;
|
||||
writeout();
|
||||
@dhcpconf = @conf;
|
||||
@dhcp6conf = @conf6;
|
||||
if (restart_dhcpd()) {
|
||||
$callback->({ error => ["Unable to restart the DHCP server with the new configuration in $dhcpconffile"], errorcode => [1] });
|
||||
return;
|
||||
}
|
||||
unlink($pending);
|
||||
}
|
||||
|
||||
#Have nodes to update
|
||||
#open2($omshellout,$omshell,"/usr/bin/omshell");
|
||||
($omshell, $omshellpid) = _open_omshell_writer($settings);
|
||||
@@ -2651,7 +2678,7 @@ sub process_request
|
||||
restart_dhcpd_aix();
|
||||
}
|
||||
else {
|
||||
restart_dhcpd();
|
||||
unlink($pending) unless restart_dhcpd();
|
||||
print "xx";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user