mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-10-06 17:46:55 +00:00
fix(dhcp): decide the Debian interface variables from the version given
debian_sysconfig_interface_keys fell back to querying the local dpkg when it was handed no version. The caller always passes one, so the fallback bought nothing -- and it made the "version could not be established" case answer differently depending on whether the machine running the code happened to have isc-dhcp-server installed. It passed on a developer's EL workstation and failed on the Ubuntu CI runner, which is the failure it was always going to produce. An undefined version now means what the caller means by it: could not be established, so write every spelling. Covered by a test that stubs the lookup to prove the answer no longer depends on the machine.
This commit is contained in:
@@ -3230,8 +3230,11 @@ sub isc_dhcp_installed_version
|
||||
# systemd host runs it, so that bridge cannot be relied on.
|
||||
sub debian_sysconfig_interface_keys
|
||||
{
|
||||
# The caller establishes the version, so what is passed here is the whole
|
||||
# input: an undefined version means "could not be established", never "go
|
||||
# and look at whatever this machine happens to have installed". The result
|
||||
# is then the same on any machine, which is what makes it testable.
|
||||
my $version = shift;
|
||||
$version = isc_dhcp_installed_version() unless (defined($version));
|
||||
|
||||
# With no version to go on, write both spellings. An unset variable expands
|
||||
# to nothing and leaves dhcpd binding every interface on the machine, which
|
||||
|
||||
@@ -156,6 +156,23 @@ foreach my $unknown (undef, '', 'none') {
|
||||
}
|
||||
}
|
||||
|
||||
# ...and it means that on every machine, not just one with no isc-dhcp-server
|
||||
# on it. A writer that goes and asks the local dpkg when it is handed no
|
||||
# version answers differently on the build host than on the machine being
|
||||
# configured, which is exactly the kind of thing a test only catches once it
|
||||
# runs somewhere else.
|
||||
{
|
||||
no warnings qw(redefine once);
|
||||
local *xCAT_plugin::dhcp::isc_dhcp_installed_version = sub {
|
||||
return '4.4.3-P1-4ubuntu2';
|
||||
};
|
||||
my @keys = xCAT_plugin::dhcp::debian_sysconfig_interface_keys(undef);
|
||||
my $written = xCAT_plugin::dhcp::_sysconfig_interfaces_content(
|
||||
$stock, [@keys], ['eth1']);
|
||||
is( launched_with($written, 'INTERFACES'), 'eth1',
|
||||
'an unknown version is not silently replaced by the local package version' );
|
||||
}
|
||||
|
||||
# Ordering of the package versions themselves. 20.04 and 22.04 both ship
|
||||
# upstream 4.4.1 and are told apart only by the Debian revision, so a
|
||||
# comparison that stops at the upstream version puts them on the wrong side.
|
||||
|
||||
Reference in New Issue
Block a user