mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-24 16:54:03 +00:00
Merge pull request #7839 from VersatusHPC/fix/ubuntu-node-netplan-search-domain
fix(xcat-core): a compute node cannot resolve the management node by short name
This commit is contained in:
@@ -90,9 +90,9 @@ autoinstall:
|
||||
installmac="#SUBIQUITYINSTALLMAC#";
|
||||
mkdir -p /target/etc/netplan;
|
||||
if [ -z "${installnic}" ]; then
|
||||
printf ''%s\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \"${installmac}\"" " dhcp4: true" >/target/etc/netplan/00-xcat-install.yaml;
|
||||
printf ''%s\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \"${installmac}\"" " dhcp4: true" " dhcp4-overrides:" " use-domains: true" >/target/etc/netplan/00-xcat-install.yaml;
|
||||
else
|
||||
printf ''%s\n'' "network:" " version: 2" " ethernets:" " xcat-install:" " match:" " macaddress: \"${installmac}\"" " set-name: ${installnic}" " dhcp4: true" >/target/etc/netplan/00-xcat-install.yaml;
|
||||
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;
|
||||
fi;
|
||||
chmod 600 /target/etc/netplan/00-xcat-install.yaml;
|
||||
printf ''%s\n'' ''#HOSTNAME#'' >/target/etc/hostname;
|
||||
|
||||
@@ -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,16 @@ 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
|
||||
# drops the search domain DHCP offers, and no single-label name resolves on the node.
|
||||
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