mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-26 20:32:17 +00:00
test(xcat-core): an IPv6-only Ubuntu diskless node gets no address in the initrd
grub2 adds BOOTIF= to the kernel command line of every node. On Ubuntu 26.04, systemd-network-generator then writes 70-BOOTIF.network with no address. It drops an ip= that names no interface, and a file for a named interface sorts after 70-BOOTIF.network. debian.pm gives the static ip= an empty interface when the node has no installnic or primarynic. The test drives static_ip6_boot_arg with the net_params of the caller. It expects rd.bootif=0 on every static ip=, and ifname=xcatboot0:<mac> when the node has no installnic. 5 of its 9 assertions fail before the fix. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -29,7 +29,7 @@ die "could not extract static_ip6_boot_arg from debian.pm" unless defined $sub;
|
||||
|
||||
{
|
||||
package T;
|
||||
eval "$sub; 1" or main::BAIL_OUT("could not eval static_ip6_boot_arg: $@");
|
||||
eval "$sub; 1" or die "could not eval static_ip6_boot_arg: $@";
|
||||
}
|
||||
|
||||
# The placeholder is resolved before it reaches the boot argument.
|
||||
@@ -37,8 +37,8 @@ die "could not extract static_ip6_boot_arg from debian.pm" unless defined $sub;
|
||||
my @asked;
|
||||
my $cfg6 = sub { return ( '2001:db8::10', $_[0], '<xcatmaster>', 64 ) };
|
||||
my $resolve = sub { push @asked, [@_]; return '2001:db8::1' };
|
||||
is( T::static_ip6_boot_arg( 'cn1', 'ens3', $cfg6, $resolve ),
|
||||
'ip=[2001:db8::10]::[2001:db8::1]:64::ens3:none',
|
||||
is( T::static_ip6_boot_arg( 'cn1', { nicname => 'ens3' }, $cfg6, $resolve ),
|
||||
'rd.bootif=0 ip=[2001:db8::10]::[2001:db8::1]:64::ens3:none',
|
||||
'the gateway is resolved before it reaches the boot argument' );
|
||||
is_deeply( \@asked, [ [ 'cn1', '<xcatmaster>' ] ],
|
||||
'... through the helper that knows the placeholder' );
|
||||
@@ -48,8 +48,8 @@ die "could not extract static_ip6_boot_arg from debian.pm" unless defined $sub;
|
||||
{
|
||||
my $cfg6 = sub { return ( '2001:db8::10', $_[0], '<xcatmaster>', 64 ) };
|
||||
my $resolve = sub { return };
|
||||
my $arg = T::static_ip6_boot_arg( 'cn1', 'ens3', $cfg6, $resolve );
|
||||
is( $arg, 'ip=[2001:db8::10]:::64::ens3:none',
|
||||
my $arg = T::static_ip6_boot_arg( 'cn1', { nicname => 'ens3' }, $cfg6, $resolve );
|
||||
is( $arg, 'rd.bootif=0 ip=[2001:db8::10]:::64::ens3:none',
|
||||
'an unresolvable gateway leaves the field empty' );
|
||||
unlike( $arg, qr/xcatmaster/, '... and the placeholder does not reach the command line' );
|
||||
}
|
||||
@@ -58,7 +58,7 @@ die "could not extract static_ip6_boot_arg from debian.pm" unless defined $sub;
|
||||
{
|
||||
my $cfg6 = sub { return ( '2001:db8::10', $_[0], '2001:db8::fe', 64 ) };
|
||||
my $resolve = sub { return $_[1] };
|
||||
like( T::static_ip6_boot_arg( 'cn1', 'ens3', $cfg6, $resolve ),
|
||||
like( T::static_ip6_boot_arg( 'cn1', { nicname => 'ens3' }, $cfg6, $resolve ),
|
||||
qr/\Q::[2001:db8::fe]:\E/,
|
||||
'a literal gateway reaches the boot argument bracketed' );
|
||||
}
|
||||
@@ -67,8 +67,28 @@ die "could not extract static_ip6_boot_arg from debian.pm" unless defined $sub;
|
||||
{
|
||||
my $cfg6 = sub { return ( undef, $_[0], undef, undef ) };
|
||||
my $resolve = sub { return $_[1] };
|
||||
is( T::static_ip6_boot_arg( 'cn1', 'ens3', $cfg6, $resolve ), undef,
|
||||
is( T::static_ip6_boot_arg( 'cn1', { nicname => 'ens3' }, $cfg6, $resolve ), undef,
|
||||
'a node with no address gets no argument' );
|
||||
}
|
||||
|
||||
# grub2 adds BOOTIF= to every node. The systemd-network-generator of Ubuntu 26.04 then writes
|
||||
# 70-BOOTIF.network, which sorts before the file that ip= names and carries no address, and it
|
||||
# drops an ip= that names no interface. rd.bootif=0 removes that file, and a node with no
|
||||
# installnic gets an interface name from its MAC, as on EL.
|
||||
{
|
||||
my $cfg6 = sub { return ( '2001:db8::10', $_[0], '2001:db8::1', 64 ) };
|
||||
my $resolve = sub { return $_[1] };
|
||||
is( T::static_ip6_boot_arg( 'cn1', { mac => '52:54:00:AA:BB:CC' }, $cfg6, $resolve ),
|
||||
'ifname=xcatboot0:52:54:00:aa:bb:cc rd.bootif=0 '
|
||||
. 'ip=[2001:db8::10]::[2001:db8::1]:64::xcatboot0:none',
|
||||
'a node with no installnic names its boot interface by MAC' );
|
||||
is( T::static_ip6_boot_arg( 'cn1', { nicname => 'ens3', mac => '52:54:00:aa:bb:cc' },
|
||||
$cfg6, $resolve ),
|
||||
'rd.bootif=0 ip=[2001:db8::10]::[2001:db8::1]:64::ens3:none',
|
||||
'... and a node with an installnic keeps that name' );
|
||||
is( T::static_ip6_boot_arg( 'cn1', {}, $cfg6, $resolve ),
|
||||
'rd.bootif=0 ip=[2001:db8::10]::[2001:db8::1]:64:::none',
|
||||
'a node with no MAC still turns off BOOTIF=, so ip= is not dropped' );
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
Reference in New Issue
Block a user