mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-20 17:32:15 +00:00
fix(xcat-core): a static IPv6 kickstart install leaves the node with no resolv.conf
site.nameservers holds one list for the whole cluster, and on a normal lab it names IPv4 resolvers. _static_kickstart_network6 in Template.pm kept only the entries that resolve to an IPv6 address, so it rendered no --nameserver at all and the installed node had no /etc/resolv.conf. Measured on a riscv64 openEuler install. EL 10 takes the same path, and EL 8 and EL 9 now take it too, so the number of nodes exposed grows. _autoyast_network6 in the same file already answered this: it maps '<xcatmaster>' through ipv6_server_for_node and falls back to the management node when the cluster configures no IPv6 resolver. The chooser is now one sub, _ipv6_nameservers_for_node, and both callers use it. The fallback is the management node and not the gateway, because a gateway can be a router that serves no DNS. A management node with no address on the network of the node yields no resolver, rather than a guess. template_ipv6_rendering.t asserts the rendered network line for all three cases. Without the fallback the IPv4-resolver case fails while the configured IPv6 resolver case and the no-address control keep passing, and autoyast_ipv6_network.t goes red with it, which shows both callers read the same chooser. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -97,6 +97,36 @@ sub _dynamic_kickstart_network
|
||||
return $network;
|
||||
}
|
||||
|
||||
# The IPv6 resolvers of a node. site.nameservers holds one list for the whole cluster, so an
|
||||
# IPv6-only node can be given the IPv4 resolver of another network. It cannot reach that
|
||||
# resolver, and an unreachable server in resolv.conf makes every lookup wait for its timeout.
|
||||
#
|
||||
# '<xcatmaster>' is the management node, which runs named. It stands in when the cluster
|
||||
# configures no IPv6 resolver, because a node with none writes no resolv.conf at all. It is not
|
||||
# the gateway: a cluster whose gateway is a separate router would be given a resolver that
|
||||
# answers nothing, and a cluster with no gateway would be given none at all.
|
||||
#
|
||||
# A management node with no address on the network of the node yields no resolver, rather than
|
||||
# a guess.
|
||||
sub _ipv6_nameservers_for_node
|
||||
{
|
||||
my ($candidate) = @_;
|
||||
|
||||
my %nameservers = %{ xCAT::NetworkUtils->getNodeNameservers([$candidate]) };
|
||||
my @resolvers;
|
||||
foreach my $nameserver (split(/,/, $nameservers{$candidate} // '')) {
|
||||
next unless length($nameserver);
|
||||
my $resolved = xCAT::NetworkUtils->ipv6_server_for_node($candidate, $nameserver);
|
||||
push @resolvers, $resolved
|
||||
if defined($resolved) && index($resolved, ':') >= 0;
|
||||
}
|
||||
return @resolvers if @resolvers;
|
||||
|
||||
my $master6 = xCAT::NetworkUtils->ipv6_server_for_node($candidate, '<xcatmaster>');
|
||||
return ($master6) if defined($master6) && index($master6, ':') >= 0;
|
||||
return ();
|
||||
}
|
||||
|
||||
sub _static_kickstart_network6
|
||||
{
|
||||
my ($candidate, $suffix) = @_;
|
||||
@@ -120,13 +150,7 @@ sub _static_kickstart_network6
|
||||
$network .= " --ipv6gateway=$gateway" if defined($gateway) && length($gateway);
|
||||
$network .= " --hostname=$hostname" if defined($hostname) && length($hostname);
|
||||
|
||||
my %nameservers = %{ xCAT::NetworkUtils->getNodeNameservers([$candidate]) };
|
||||
my @nameserver_ips;
|
||||
foreach my $nameserver (split(/,/, $nameservers{$candidate} || '')) {
|
||||
next unless length($nameserver);
|
||||
my $resolved = xCAT::NetworkUtils->ipv6_server_for_node($candidate, $nameserver);
|
||||
push @nameserver_ips, $resolved if $resolved;
|
||||
}
|
||||
my @nameserver_ips = _ipv6_nameservers_for_node($candidate);
|
||||
$network .= " --nameserver=" . join(',', @nameserver_ips) if @nameserver_ips;
|
||||
|
||||
return $network;
|
||||
@@ -1370,22 +1394,7 @@ sub _autoyast_network6 {
|
||||
|
||||
my $nd = xCAT::NetworkUtils->getNodeDomains([$node]);
|
||||
my $domain = $nd->{$node};
|
||||
my %nameservers = %{ xCAT::NetworkUtils->getNodeNameservers([$node]) };
|
||||
# site.nameservers holds one list for the cluster, so the node can be given the IPv4
|
||||
# resolver of another network. An IPv6-only node cannot reach it, and an unreachable
|
||||
# server in resolv.conf makes every lookup wait for its timeout.
|
||||
#
|
||||
# '<xcatmaster>' is the management node, which runs named. It is not the gateway: a
|
||||
# cluster whose gateway is a separate router would be given a resolver that answers
|
||||
# nothing, and a cluster with no gateway would be given none at all.
|
||||
my $master6 = xCAT::NetworkUtils->ipv6_server_for_node($node, '<xcatmaster>');
|
||||
my @nameserversIP = grep { index($_, ':') >= 0 }
|
||||
grep { defined && length }
|
||||
map { $_ eq '<xcatmaster>' ? $master6 : $_ } split(/,/, $nameservers{$node} // '');
|
||||
@nameserversIP = ($master6)
|
||||
if !@nameserversIP
|
||||
&& defined($master6)
|
||||
&& index($master6, ':') >= 0;
|
||||
my @nameserversIP = _ipv6_nameservers_for_node($node);
|
||||
|
||||
my $interface = {
|
||||
'bootproto' => ['static'],
|
||||
|
||||
@@ -18,6 +18,9 @@ use xCAT::Template;
|
||||
my %addresses = (
|
||||
nodev4 => { 4 => '192.0.2.50' },
|
||||
nodev6 => { 6 => '2001:db8:1::50' },
|
||||
# A node whose gateway is a literal router address, not the management node. The two must
|
||||
# differ, or a resolver test cannot tell the management node from the gateway.
|
||||
nodev6lit => { 6 => '2001:db8:1::51' },
|
||||
nodedual => { 4 => '192.0.2.60', 6 => '2001:db8:1::60' },
|
||||
'master4.example.test' => { 4 => '192.0.2.1' },
|
||||
'master6.example.test' => { 6 => '2001:db8::1' },
|
||||
@@ -35,22 +38,31 @@ local *xCAT::NetworkUtils::getipaddr = sub {
|
||||
return $entry->{4} if $opts{OnlyV4};
|
||||
return $entry->{4} || $entry->{6};
|
||||
};
|
||||
# The address of the management node on the network of the node. An MN with none is the
|
||||
# control of the resolver fallback below: it must yield no resolver rather than a guess.
|
||||
our $master_facing6 = '2001:db8::1';
|
||||
local *xCAT::NetworkUtils::my_ip_facing_family = sub {
|
||||
my $node = shift;
|
||||
$node = shift if defined($node) && $node eq 'xCAT::NetworkUtils';
|
||||
my $family = shift;
|
||||
push @facing_calls, [$node, $family];
|
||||
return (0, '2001:db8::1');
|
||||
return (1, undef) unless defined($master_facing6);
|
||||
return (0, $master_facing6);
|
||||
};
|
||||
local *xCAT::NetworkUtils::getNodeNetworkCfg6 = sub {
|
||||
my $candidate = shift;
|
||||
$candidate = shift if defined($candidate) && $candidate eq 'xCAT::NetworkUtils';
|
||||
return ('2001:db8:1::51', $candidate, '2001:db8:1::fe', 64)
|
||||
if $candidate eq 'nodev6lit';
|
||||
return ('2001:db8:1::50', $candidate, '<xcatmaster>', 64);
|
||||
};
|
||||
# site.nameservers holds one list for the whole cluster, so it can name resolvers the node
|
||||
# cannot reach.
|
||||
our $site_nameservers = 'dns6.example.test,192.0.2.53';
|
||||
local *xCAT::NetworkUtils::getNodeNameservers = sub {
|
||||
my $nodes = shift;
|
||||
$nodes = shift if defined($nodes) && $nodes eq 'xCAT::NetworkUtils';
|
||||
return { $nodes->[0] => 'dns6.example.test,192.0.2.53' };
|
||||
return { $nodes->[0] => $site_nameservers };
|
||||
};
|
||||
|
||||
is(
|
||||
@@ -196,6 +208,34 @@ foreach my $el_os (qw(alma8.10 rhels9.6)) {
|
||||
"$el_os does not ask DHCPv6 from the installer");
|
||||
}
|
||||
|
||||
# The resolver of a statically configured IPv6-only node. site.nameservers names the IPv4
|
||||
# resolver of the cluster on a normal lab, so no resolver reached the node and it installed
|
||||
# with no /etc/resolv.conf.
|
||||
{
|
||||
local $site_nameservers = '192.168.177.1';
|
||||
my $v4ns = render_minimal_template('nodev6lit', 'master6.example.test', undef, 'alma9.6');
|
||||
like($v4ns, qr/^network .* --nameserver=2001:db8::1$/m,
|
||||
'an IPv4 site resolver is replaced by the IPv6 address of the management node');
|
||||
unlike($v4ns, qr/--nameserver=[^ ]*192\.168\.177\.1/,
|
||||
'and the IPv4 resolver itself does not reach the node');
|
||||
unlike($v4ns, qr/--nameserver=[^ ]*2001:db8:1::fe/,
|
||||
'and not by the gateway, which can be a router that serves no DNS');
|
||||
}
|
||||
{
|
||||
local $site_nameservers = '2001:db8:aa::53';
|
||||
my $v6ns = render_minimal_template('nodev6lit', 'master6.example.test', undef, 'alma9.6');
|
||||
like($v6ns, qr/^network .* --nameserver=2001:db8:aa::53$/m,
|
||||
'a configured IPv6 resolver is kept as it stands');
|
||||
}
|
||||
{
|
||||
# The control: an MN with no address on the network of the node has no resolver to offer.
|
||||
local $site_nameservers = '192.168.177.1';
|
||||
local $master_facing6 = undef;
|
||||
my $none = render_minimal_template('nodev6lit', 'master6.example.test', undef, 'alma9.6');
|
||||
unlike($none, qr/--nameserver/,
|
||||
'a management node with no address on the network yields no resolver at all');
|
||||
}
|
||||
|
||||
my $v4_rendered = render_minimal_template('nodev4', 'master4.example.test');
|
||||
like(
|
||||
$v4_rendered,
|
||||
|
||||
Reference in New Issue
Block a user