mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 01:42:15 +00:00
merge(xcat-core): take fix/ubuntu-netboot-dracut-ng-systemd-initrd into releases/2.20.0-rc8
An Ubuntu 26.04 diskless node freezes in the initial ramdisk at 1.78 s with 'Failed to isolate default target: Unit rescue.service not found'. genimage writes an exclusive dracutmodules list, dracut 110 drops 35network-legacy, so 11systemd-networkd is selected, 80base then makes systemd the init, and the list names neither systemd-initrd nor dracut-systemd, so there is no default target. rh/genimage already names those three for dracut 105 and later. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -284,6 +284,33 @@ sub disable_auto_profiles {
|
||||
return;
|
||||
}
|
||||
|
||||
# The netboot dracut.conf names an exclusive module list, so a module nothing in the list depends
|
||||
# on is left out of the initial ramdisk. dracut reads the list and nothing else.
|
||||
#
|
||||
# dracut-ng removed the network-legacy module. Without it 40network selects systemd-networkd, which
|
||||
# depends on the systemd module, and the base module installs the shell /init only when systemd is
|
||||
# out. systemd as /init needs initrd.target, which the systemd-initrd module installs, and the
|
||||
# dracut hooks need the units of the dracut-systemd module. The EL genimage names the same three.
|
||||
sub dracut_netboot_modules {
|
||||
my ($moduledir, $wicked) = @_;
|
||||
my $legacy = -d "$moduledir/35network-legacy" ? 1 : 0;
|
||||
my $netmod = ($legacy && !$wicked) ? 'network-legacy' : 'network';
|
||||
my @modules = ('xcat', 'nfs', 'base', $netmod, 'kernel-modules');
|
||||
return join(' ', @modules) if $legacy;
|
||||
my %present;
|
||||
if (opendir(my $dh, $moduledir)) {
|
||||
|
||||
# A dracut module directory carries a number that orders it, and the number moves between
|
||||
# dracut releases. The name after the number is what dracut.conf names.
|
||||
foreach my $entry (readdir($dh)) {
|
||||
$present{$1} = 1 if $entry =~ /^[0-9]+(.+)$/ && -d "$moduledir/$entry";
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
push @modules, grep { $present{$_} } qw(systemd systemd-initrd dracut-systemd);
|
||||
return join(' ', @modules);
|
||||
}
|
||||
|
||||
# debootstrap deletes $rootimg_dir/debootstrap when it finishes, and its tar -k fails over a finished root.
|
||||
sub debootstrap_finished {
|
||||
my ($rootimg_dir) = @_;
|
||||
|
||||
@@ -1019,13 +1019,10 @@ sub mkinitrd_dracut {
|
||||
$perm = (stat("$fullpath/$dracutdir/xcat-prepivot.sh"))[2];
|
||||
chmod($perm & 07777, "$dracutmpath/xcat-prepivot.sh");
|
||||
|
||||
# update etc/dracut.conf - use network-legacy if 40network requires wicked
|
||||
my $netmod = "network";
|
||||
if (-d "$dracutmpath/../35network-legacy" && ! -x "$rootimg_dir/usr/sbin/wicked") {
|
||||
$netmod = "network-legacy";
|
||||
}
|
||||
# update etc/dracut.conf
|
||||
my $dracutmodulelist = imgutils::dracut_netboot_modules(dirname($dracutmpath), -x "$rootimg_dir/usr/sbin/wicked");
|
||||
open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
|
||||
print $DRACUTCONF qq{dracutmodules+=" xcat nfs base $netmod kernel-modules "\n};
|
||||
print $DRACUTCONF qq{dracutmodules+=" $dracutmodulelist "\n};
|
||||
print $DRACUTCONF qq{add_drivers+=" $add_drivers "\n};
|
||||
print $DRACUTCONF qq{filesystems+=" nfs "\n};
|
||||
close $DRACUTCONF;
|
||||
@@ -1053,13 +1050,10 @@ sub mkinitrd_dracut {
|
||||
$perm = (stat("$fullpath/$dracutdir/installkernel"))[2];
|
||||
chmod($perm & 07777, "$dracutmpath/installkernel");
|
||||
|
||||
# update etc/dracut.conf - use network-legacy if 40network requires wicked
|
||||
my $netmod = "network";
|
||||
if (-d "$dracutmpath/../35network-legacy" && ! -x "$rootimg_dir/usr/sbin/wicked") {
|
||||
$netmod = "network-legacy";
|
||||
}
|
||||
# update etc/dracut.conf
|
||||
my $dracutmodulelist = imgutils::dracut_netboot_modules(dirname($dracutmpath), -x "$rootimg_dir/usr/sbin/wicked");
|
||||
open($DRACUTCONF, '>', "$rootimg_dir/etc/dracut.conf");
|
||||
print $DRACUTCONF qq{dracutmodules+=" xcat nfs base $netmod kernel-modules "\n};
|
||||
print $DRACUTCONF qq{dracutmodules+=" $dracutmodulelist "\n};
|
||||
print $DRACUTCONF qq{add_drivers+=" $add_drivers "\n};
|
||||
close $DRACUTCONF;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use FindBin;
|
||||
use File::Path qw(make_path);
|
||||
use File::Temp qw(tempdir);
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/lib/perl";
|
||||
use lib "$FindBin::Bin/../../xCAT-server/share/xcat/netboot/imgutils";
|
||||
use Test::More;
|
||||
use imgutils;
|
||||
|
||||
# Builds a modules.d that holds the named dracut modules and nothing else.
|
||||
sub modules_dir {
|
||||
my (@modules) = @_;
|
||||
my $dir = tempdir(CLEANUP => 1);
|
||||
make_path("$dir/$_") for @modules;
|
||||
return $dir;
|
||||
}
|
||||
|
||||
# dracut 060 on noble. 40network takes network-legacy, so dracut writes the shell /init.
|
||||
{
|
||||
my $dir = modules_dir(qw(35network-legacy 10systemd 11systemd-initrd 77dracut-systemd 97xcat));
|
||||
is(imgutils::dracut_netboot_modules($dir, 0), 'xcat nfs base network-legacy kernel-modules',
|
||||
'a dracut that holds network-legacy keeps the module list it had');
|
||||
}
|
||||
|
||||
# dracut 110 on resolute. network-legacy is gone, so 40network takes systemd-networkd and dracut
|
||||
# writes systemd as /init. systemd needs initrd.target, which the systemd-initrd module installs.
|
||||
{
|
||||
my $dir = modules_dir(qw(10systemd 11systemd-initrd 77dracut-systemd 40network 74nfs 97xcat));
|
||||
is(imgutils::dracut_netboot_modules($dir, 0),
|
||||
'xcat nfs base network kernel-modules systemd systemd-initrd dracut-systemd',
|
||||
'a dracut without network-legacy gets the systemd modules its initial ramdisk needs');
|
||||
}
|
||||
|
||||
# The module names carry no version prefix, so a number the next dracut picks must not matter.
|
||||
{
|
||||
my $dir = modules_dir(qw(00systemd 01systemd-initrd 98dracut-systemd 97xcat));
|
||||
is(imgutils::dracut_netboot_modules($dir, 0),
|
||||
'xcat nfs base network kernel-modules systemd systemd-initrd dracut-systemd',
|
||||
'the systemd modules are found under the numbers an older dracut uses');
|
||||
}
|
||||
|
||||
# A module that is not in the image cannot be put in the list.
|
||||
{
|
||||
my $dir = modules_dir(qw(10systemd 97xcat));
|
||||
is(imgutils::dracut_netboot_modules($dir, 0), 'xcat nfs base network kernel-modules systemd',
|
||||
'only the systemd modules the image holds are named');
|
||||
}
|
||||
|
||||
# 35network-legacy requires wicked, which a Debian image does not have.
|
||||
{
|
||||
my $dir = modules_dir(qw(35network-legacy 10systemd 11systemd-initrd 77dracut-systemd 97xcat));
|
||||
is(imgutils::dracut_netboot_modules($dir, 1), 'xcat nfs base network kernel-modules',
|
||||
'an image with wicked keeps the network module and the list it had');
|
||||
}
|
||||
|
||||
# genimage calls this before dracut runs, and the path comes from the image.
|
||||
{
|
||||
my $dir = tempdir(CLEANUP => 1);
|
||||
is(imgutils::dracut_netboot_modules("$dir/absent", 0), 'xcat nfs base network kernel-modules',
|
||||
'a modules directory that does not exist returns the plain list');
|
||||
}
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user