mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-25 17:24:07 +00:00
test(xcat-core): the Ubuntu node netplan discards the DHCP search domain
The netplan xCAT writes for a compute node sets dhcp4: true and nothing else, so systemd-networkd keeps its UseDomains default of no. The node takes the DNS server from DHCP and drops the offered domain-search, and no single-label name resolves on the installed node. Assert the rendered netplan asks networkd to use the DHCP domains. The assertion runs the template's own late-command, so it reads the file the installer writes, not the template text. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -98,7 +98,7 @@ $tmpl_path = "$FindBin::Bin/../../xCAT-server/share/xcat/install/ubuntu/compute.
|
||||
unless -f $tmpl_path;
|
||||
|
||||
SKIP: {
|
||||
skip 'compute.subiquity.tmpl not found', 4 unless -f $tmpl_path;
|
||||
skip 'compute.subiquity.tmpl not found', 6 unless -f $tmpl_path;
|
||||
my $tmpl = do { local $/; open my $fh, '<', $tmpl_path or die $!; <$fh> };
|
||||
|
||||
# The netplan-writing part of late-commands, verbatim: from the resolved values down to the
|
||||
@@ -106,7 +106,7 @@ SKIP: {
|
||||
my ($snippet) = $tmpl =~ /(installnic="#SUBIQUITYINSTALLNIC#".*?fi;)/s;
|
||||
ok($snippet, 'the netplan late-command is rendered from the resolved values');
|
||||
|
||||
skip 'netplan late-command not found in the template', 3 unless $snippet;
|
||||
skip 'netplan late-command not found in the template', 5 unless $snippet;
|
||||
$snippet =~ s/''/'/g; # undo the YAML single-quote escaping
|
||||
|
||||
for my $case (
|
||||
@@ -132,9 +132,18 @@ SKIP: {
|
||||
' match:', qq( macaddress: "$case->{mac}"),
|
||||
($case->{setname} ne '' ? " set-name: $case->{setname}" : ()),
|
||||
' dhcp4: true',
|
||||
' dhcp4-overrides:',
|
||||
' use-domains: true',
|
||||
);
|
||||
is($netplan, join("\n", @expected) . "\n",
|
||||
"the netplan written for $case->{name} matches the resolved values");
|
||||
|
||||
# systemd-networkd defaults UseDomains to no, so a netplan carrying dhcp4: true alone
|
||||
# takes the DNS server from DHCP and drops the offered domain-search. The node then
|
||||
# resolves no single-label name: updateflag.awk runs "$MASTER 3002" with the short
|
||||
# management node name, cannot resolve it, and the node never leaves postbooting.
|
||||
like($netplan, qr/^\s+use-domains: true$/m,
|
||||
"the netplan for $case->{name} asks networkd to use the DHCP search domain");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,10 +59,11 @@ unlike($tmpl, qr/tr ''A-F'' ''a-f''/,
|
||||
'the shell no longer normalizes the MAC (Template.pm resolves mac.mac entries)');
|
||||
unlike($tmpl, qr/cut -d''\|'' -f1/,
|
||||
'the shell no longer splits mac.mac entries (Template.pm resolves them for this node)');
|
||||
like($tmpl, qr/printf ''%s\\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \\"\$\{installmac\}\\"" " set-name: \$\{installnic\}" " dhcp4: true" >\/target\/etc\/netplan\/00-xcat-install\.yaml;/, 'target netplan printf stays on one shell line');
|
||||
like($tmpl, qr/printf ''%s\\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \\"\$\{installmac\}\\"" " set-name: \$\{installnic\}" " dhcp4: true" " dhcp4-overrides:" " use-domains: true" >\/target\/etc\/netplan\/00-xcat-install\.yaml;/, 'target netplan printf stays on one shell line');
|
||||
like($tmpl, qr/" macaddress: \\"\$\{installmac\}\\""/, 'target netplan matches by MAC address');
|
||||
like($tmpl, qr/" set-name: \$\{installnic\}"/, 'target netplan sets the expected installnic name');
|
||||
like($tmpl, qr/"\s+dhcp4: true"/, 'target netplan enables DHCPv4 on installnic');
|
||||
like($tmpl, qr/"\s+use-domains: true"/, 'target netplan takes the search domain DHCP offers, so short names resolve on the node');
|
||||
like($tmpl, qr/printf ''%s\\n'' ''#HOSTNAME#'' >\/target\/etc\/hostname/, 'template writes target hostname before disabling cloud-init');
|
||||
like($tmpl, qr/sed -i ''s\/\^127\\\.0\\\.1\\\.1\.\*\/127\.0\.1\.1 #HOSTNAME#\/'' \/target\/etc\/hosts/, 'template updates target hosts entry for hostname');
|
||||
like($tmpl, qr/touch \/target\/etc\/cloud\/cloud-init\.disabled/, 'target cloud-init is disabled after target netplan is written');
|
||||
|
||||
Reference in New Issue
Block a user