All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit fec216a4 authored by David Johnson's avatar David Johnson

Add support for alternate recovery mfs in libadminfs.

(There is also a grotesque hack for noticing that an MFS needs to be
booted via an alternate pxe_boot_path.)
parent d1fef708
...@@ -45,6 +45,8 @@ use vars qw(@ISA @EXPORT); ...@@ -45,6 +45,8 @@ use vars qw(@ISA @EXPORT);
use libdb; use libdb;
use libtestbed; use libtestbed;
use StateWait; use StateWait;
use OSImage;
use Node;
# #
# Function prototypes # Function prototypes
...@@ -66,6 +68,7 @@ my $nodereboot = "$TB/bin/node_reboot"; ...@@ -66,6 +68,7 @@ my $nodereboot = "$TB/bin/node_reboot";
my $power = "$TB/bin/power"; my $power = "$TB/bin/power";
my $osselect = "$TB/bin/os_select"; my $osselect = "$TB/bin/os_select";
my $nfsmfssetup = "$TB/sbin/nfsmfs_setup"; my $nfsmfssetup = "$TB/sbin/nfsmfs_setup";
my $dhcpd_makeconf = "$TB/sbin/dhcpd_makeconf";
# #
# The number of nodes we will power on at a time and the time to wait # The number of nodes we will power on at a time and the time to wait
...@@ -345,6 +348,8 @@ sub TBAdminMfsSelect($$@) ...@@ -345,6 +348,8 @@ sub TBAdminMfsSelect($$@)
} }
# and set it # and set it
my $pxechanged = 0;
my @admingood = ();
for my $osid (keys %adminosid) { for my $osid (keys %adminosid) {
my @n = @{$adminosid{$osid}}; my @n = @{$adminosid{$osid}};
if (system("$osselect -t $osid @n")) { if (system("$osselect -t $osid @n")) {
...@@ -353,13 +358,64 @@ sub TBAdminMfsSelect($$@) ...@@ -353,13 +358,64 @@ sub TBAdminMfsSelect($$@)
push(@bad, @n); push(@bad, @n);
} else { } else {
push(@good, @n); push(@good, @n);
# Construct the good list for nodes that are booting the
# admin MFS; this list may be different than the @good
# list (some nodes may boot the recovery MFS, for
# instance).
foreach my $nodeid (@n) {
if (TBNodeAdminOSID($nodeid) == $osid) {
push @admingood, $nodeid;
}
}
#
# See if this OSID requires a different pxeboot program.
# If the OSID is a Linux MFS that needs to be booted by
# grub2pxe, and if the node or node type has the
# grub2pxe_path attribute, then change next_pxe_boot_path.
#
# If the default pxe_boot_path node/type attr is already
# a grub2pxe, no need to set the grub2pxe_path node/type
# attr for this to work.
#
my $osi = OSImage->Lookup($osid);
my $path = $osi->osinfo()->path();
if (-e "$path/grub.cfg") {
foreach my $nodeid (@n) {
my $nodeobject = Node->Lookup($nodeid);
my $gp;
$nodeobject->NodeAttribute('grub2pxe_path',\$gp);
if (!defined($gp)) {
$nodeobject->NodeTypeAttribute('grub2pxe_path',\$gp);
}
next
if (!defined($gp));
my $node_pxechanged = 0;
if ($nodeobject->PXESelect($gp, "next_pxe_boot_path",
0, \$node_pxechanged)) {
print STDERR "$me: pxe_select $nodeid $gp failed!";
next;
}
$pxechanged += $node_pxechanged;
}
}
} }
} }
if ($pxechanged && system("$dhcpd_makeconf -i -r")) {
print STDERR "*** $me: restart DHCPD failed!";
return 1;
}
#
# Possibly construct a dynamic NFS MFS for some nodes, but only
# for those that are going to load the node/type default admin
# mfs, because that is all the NFS MFS creation script supports.
#
my %cargs; my %cargs;
$cargs{'name'} = $me; $cargs{'name'} = $me;
my @cfailed = (); my @cfailed = ();
if (TBAdminMfsCreate(\%cargs, \@cfailed, @good)) { if (@admingood && TBAdminMfsCreate(\%cargs, \@cfailed, @admingood)) {
print STDERR "*** $me:\n". print STDERR "*** $me:\n".
" Failed to create NFS FS for @cfailed; ". " Failed to create NFS FS for @cfailed; ".
"continuing, but those nodes won't boot!\n"; "continuing, but those nodes won't boot!\n";
...@@ -383,11 +439,33 @@ sub TBAdminMfsSelect($$@) ...@@ -383,11 +439,33 @@ sub TBAdminMfsSelect($$@)
} }
@good = @nodes; @good = @nodes;
my $pxechanged = 0;
foreach my $nodeid (@nodes) {
my $nodeobject = Node->Lookup($nodeid);
my $node_pxechanged = 0;
if (defined($nodeobject->next_pxe_boot_path)) {
if ($nodeobject->PXESelect("", "next_pxe_boot_path",
0, \$node_pxechanged)) {
print STDERR "$me: pxe_select $nodeid '' failed!";
next;
}
$pxechanged += $node_pxechanged;
}
}
if ($pxechanged && system("$dhcpd_makeconf -i -r")) {
print STDERR "*** $me: restart DHCPD failed!";
return 1;
}
# #
# XXX note that this is a "soft" destroy. # XXX note that this is a "soft" destroy.
# We will only rename the existing MFS so that if the node # We will only rename the existing MFS so that if the node
# is currently running on it, it will continue to function. # is currently running on it, it will continue to function.
# #
# XXX: note that we call this even if we might not be running
# the admin mfs (e.g. if we were told to run the recovery MFS
# above). This is harmless in that case.
#
my %cargs; my %cargs;
$cargs{'name'} = $me; $cargs{'name'} = $me;
my @cfailed = (); my @cfailed = ();
...@@ -648,8 +726,6 @@ sub TBAdminMfsCreate($$@) ...@@ -648,8 +726,6 @@ sub TBAdminMfsCreate($$@)
# #
my @nfsnodes = (); my @nfsnodes = ();
for my $node (@nodes) { for my $node (@nodes) {
require OSImage;
my $osobj = OSImage->Lookup(TBNodeAdminOSID($node)); my $osobj = OSImage->Lookup(TBNodeAdminOSID($node));
if ($osobj && $osobj->IsNfsMfs()) { if ($osobj && $osobj->IsNfsMfs()) {
push @nfsnodes, $node; push @nfsnodes, $node;
...@@ -709,8 +785,6 @@ sub TBAdminMfsDestroy($$@) ...@@ -709,8 +785,6 @@ sub TBAdminMfsDestroy($$@)
# #
my @nfsnodes = (); my @nfsnodes = ();
for my $node (@nodes) { for my $node (@nodes) {
require OSImage;
my $osobj = OSImage->Lookup(TBNodeAdminOSID($node)); my $osobj = OSImage->Lookup(TBNodeAdminOSID($node));
if ($osobj && $osobj->IsNfsMfs()) { if ($osobj && $osobj->IsNfsMfs()) {
push @nfsnodes, $node; push @nfsnodes, $node;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment