mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 01:42:15 +00:00
fix(template): the Subiquity install fetches from an unbracketed IPv6 server
The Subiquity templates build three URLs as "http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/...", and that tag renders the bare value of the master. For an IPv6-only node that is a literal address, so wget read the last group as a port: wget -T 30 -O /tmp/getinstdisk http://2001:db8:147::1/install/autoinst/getinstdisk http://2001:db8:147::1/install/autoinst/getinstdisk: Bad port number. The early-commands script runs under "set -eux", so that one line ended it. subiquity reported CalledProcessError from Early/run, wrote a crash report of kind "unknown", and stopped before curtin ran. Nothing in the installer logs named the cause: curtin-install.log was empty, cloud-init was healthy, and the error report that looked like the failure was the Error CONTROLLER loading its own configuration. Template.pm already computed $master_uri_host, bracketed for an IPv6-only node, and used it for the SLES media URL and the repo baseurl. It is now exposed as #MASTERURIHOST#, and the three URLs take it. #XCATVAR:XCATMASTER# keeps the bare value where it is right: bash reads /dev/tcp/<host>/<port> with no brackets, and the updateflag notification uses that form. subiquity_uri_host.t reads both templates, which are the artifact: every http:// URL has to take the URI host, the /dev/tcp line has to keep the bare one, and Template.pm has to substitute the tag. Restoring the bare tag in one URL fails two checks; dropping the substitution fails the third. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -511,6 +511,10 @@ sub subvars {
|
||||
$inc =~ s/#GETNODEDOMAIN:([^#]+)#/get_node_domain($1)/eg;
|
||||
$inc =~ s/#GETPRINICMAC:([^#]+)#/xCAT::Utils::parseMacTabEntry(tabdb("mac",$1,"mac"),$1)/eg;
|
||||
$inc =~ s/#COLONHTTPPORT#/$httpportsuffix/eg;
|
||||
# The master as a URI host: bracketed when it is an IPv6 literal, so a URL built in a
|
||||
# template can carry it. #XCATVAR:XCATMASTER# is the bare value and stays that way,
|
||||
# because bash reads /dev/tcp/<host>/<port> with no brackets.
|
||||
$inc =~ s/#MASTERURIHOST#/$master_uri_host/eg;
|
||||
|
||||
if (($::XCATSITEVALS{xcatdebugmode} eq "1") or ($::XCATSITEVALS{xcatdebugmode} eq "2")) {
|
||||
$inc =~ s/#UNCOMMENTOENABLEDEBUGPORT#//g;
|
||||
|
||||
@@ -53,12 +53,12 @@ autoinstall:
|
||||
ip addr show
|
||||
ip route show
|
||||
echo "=== disk detection ==="
|
||||
wget -T 30 -O /tmp/getinstdisk http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/getinstdisk
|
||||
wget -T 30 -O /tmp/getinstdisk http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/getinstdisk
|
||||
test -s /tmp/getinstdisk
|
||||
chmod u+x /tmp/getinstdisk
|
||||
/tmp/getinstdisk
|
||||
echo "=== pre-install script ==="
|
||||
wget -T 30 -O /tmp/pre.sh http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.pre
|
||||
wget -T 30 -O /tmp/pre.sh http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.pre
|
||||
test -s /tmp/pre.sh
|
||||
chmod u+x /tmp/pre.sh
|
||||
/tmp/pre.sh
|
||||
@@ -107,7 +107,7 @@ autoinstall:
|
||||
printf ''%s\n'' ''GRUB_CMDLINE_LINUX="#TABLEBLANKOKAY:bootparams:$NODE:kcmdline#"'' >>/target/etc/default/grub;
|
||||
curtin in-target --target /target update-grub2;
|
||||
echo "Running late_command Installation script...";
|
||||
wget -T 30 http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.post;
|
||||
wget -T 30 http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.post;
|
||||
chmod u+x #HOSTNAME#.post;
|
||||
cp ./#HOSTNAME#.post /target/root/post.script;
|
||||
curtin in-target --target /target /root/post.script;
|
||||
|
||||
@@ -53,12 +53,12 @@ autoinstall:
|
||||
ip addr show
|
||||
ip route show
|
||||
echo "=== disk detection ==="
|
||||
wget -T 30 -O /tmp/getinstdisk http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/getinstdisk
|
||||
wget -T 30 -O /tmp/getinstdisk http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/getinstdisk
|
||||
test -s /tmp/getinstdisk
|
||||
chmod u+x /tmp/getinstdisk
|
||||
/tmp/getinstdisk
|
||||
echo "=== pre-install script ==="
|
||||
wget -T 30 -O /tmp/pre.sh http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.pre
|
||||
wget -T 30 -O /tmp/pre.sh http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.pre
|
||||
test -s /tmp/pre.sh
|
||||
chmod u+x /tmp/pre.sh
|
||||
/tmp/pre.sh
|
||||
@@ -107,7 +107,7 @@ autoinstall:
|
||||
printf ''%s\n'' ''GRUB_CMDLINE_LINUX="#TABLEBLANKOKAY:bootparams:$NODE:kcmdline#"'' >>/target/etc/default/grub;
|
||||
curtin in-target --target /target update-grub2;
|
||||
echo "Running late_command Installation script...";
|
||||
wget -T 30 http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.post;
|
||||
wget -T 30 http://#MASTERURIHOST##COLONHTTPPORT#/install/autoinst/#HOSTNAME#.post;
|
||||
chmod u+x #HOSTNAME#.post;
|
||||
cp ./#HOSTNAME#.post /target/root/post.script;
|
||||
curtin in-target --target /target /root/post.script;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env perl
|
||||
# The URLs the Subiquity templates fetch from carry the master as a URI host.
|
||||
#
|
||||
# They were built as "http://#XCATVAR:XCATMASTER##COLONHTTPPORT#/install/autoinst/...", and
|
||||
# that tag renders the bare value. For an IPv6-only node that is a literal address, so wget
|
||||
# read the last group as a port:
|
||||
#
|
||||
# wget -T 30 -O /tmp/getinstdisk http://2001:db8:147::1/install/autoinst/getinstdisk
|
||||
# http://2001:db8:147::1/install/autoinst/getinstdisk: Bad port number.
|
||||
#
|
||||
# The early-commands script runs under "set -eux", so that one line failed the whole script,
|
||||
# subiquity reported CalledProcessError from Early/run, and the install stopped before curtin.
|
||||
#
|
||||
# The templates are the artifact here, so they are read. #MASTERURIHOST# renders through
|
||||
# format_uri_host, which networkutils_ipv6_helpers.t covers.
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Slurper qw(read_text);
|
||||
use File::Spec;
|
||||
use FindBin;
|
||||
use Test::More;
|
||||
|
||||
my $root = File::Spec->catdir( $FindBin::Bin, '..', '..' );
|
||||
|
||||
foreach my $kind (qw(compute service)) {
|
||||
my $tmpl = File::Spec->catfile( $root, 'xCAT-server', 'share', 'xcat', 'install',
|
||||
'ubuntu', "$kind.subiquity.tmpl" );
|
||||
SKIP: {
|
||||
skip "$kind.subiquity.tmpl not found", 4 unless -f $tmpl;
|
||||
my $text = read_text($tmpl);
|
||||
|
||||
# Every http:// URL in the template takes the URI host, never the bare tag.
|
||||
my @urls = $text =~ m{(http://#[A-Z:]+#[^ '"]*)}g;
|
||||
ok( scalar(@urls), "$kind template builds at least one URL" );
|
||||
my @bare = grep { m{^http://#XCATVAR:XCATMASTER#} } @urls;
|
||||
is_deeply( \@bare, [],
|
||||
"$kind template builds no URL from the bare master value" );
|
||||
my @uri = grep { m{^http://#MASTERURIHOST#} } @urls;
|
||||
is( scalar(@uri), scalar(@urls),
|
||||
"$kind template builds every URL from the URI host" );
|
||||
|
||||
# /dev/tcp takes a bare host, so that one keeps the bare tag.
|
||||
like( $text, qr{xm=#XCATVAR:XCATMASTER#},
|
||||
"$kind template still gives /dev/tcp the unbracketed host" );
|
||||
}
|
||||
}
|
||||
|
||||
# The tag has to be substituted, or it reaches the node as text.
|
||||
my $pm = File::Spec->catfile( $root, 'xCAT-server', 'lib', 'perl', 'xCAT', 'Template.pm' );
|
||||
SKIP: {
|
||||
skip 'Template.pm not found', 1 unless -f $pm;
|
||||
ok( index( read_text($pm), 's/#MASTERURIHOST#/$master_uri_host/' ) >= 0,
|
||||
'Template.pm substitutes the tag' );
|
||||
}
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user