diff --git a/db/libdb.pm.in b/db/libdb.pm.in index d01dfd8586f05ac1c9e0a332ac3cc4eb15235e20..2d967903a83c665b7dac5473cead0b3eb5454d93 100644 --- a/db/libdb.pm.in +++ b/db/libdb.pm.in @@ -159,7 +159,7 @@ use vars qw(@ISA @EXPORT); TBOSLoadMaxOkay TBImageLoadMaxOkay TBImageID ExpSwapper TBdbfork TBDBDisconnect VnameToNodeid TBExpLocked TBIsNodeRemote TBExptSetLogFile TBExptClearLogFile TBExptGetLogFile - TBIsNodeVirtual TBControlNetIP TBPhysNodeID + TBIsNodeImageable TBIsNodeVirtual TBControlNetIP TBPhysNodeID TBExptOpenLogFile TBExptCloseLogFile TBExptCreateLogFile TBNodeUpdateAccountsByPid TBNodeUpdateAccountsByType TBNodeUpdateAccountsByUID @@ -2609,6 +2609,30 @@ sub TBGetNodeAllocState($$) return 1; } +# +# Is a node imageable? +# +# usage TBIsNodeImageable(char *node) +# Returns 1 if yes. +# Returns 0 if no. +# +sub TBIsNodeImageable($) +{ + my ($nodeid) = @_; + + my $query_result = + DBQueryFatal("select nt.imageable from nodes as n ". + "left join node_types as nt on nt.type=n.type ". + "where n.node_id='$nodeid'"); + + if (! $query_result->num_rows) { + return 0; + } + + my @row = $query_result->fetchrow_array(); + return($row[0]); +} + # # Is a node remote? # diff --git a/db/nfree.in b/db/nfree.in index 635b2571594a764d5fd48985f702782d02a14f88..023bc3a35f4e39048d046035a3cea8fa5cc8ce52 100755 --- a/db/nfree.in +++ b/db/nfree.in @@ -351,10 +351,17 @@ foreach my $n (@freed_nodes) { $result = DBQueryFatal("select node_id,image_id from scheduled_reloads " . "where node_id='$n'"); + my $inreloads = $result->numrows(); + + # XXX + if ($inreloads && !$isimageable) { + print "WARNING: non-imageable node $n in scheduled_reloads\n"; + $inreloads = 0; + } if (!$TESTMODE && ((!$isvirt && $imageable) || # XXX force reload hack! - $result->numrows() || $mustzero{$n} || + $inreloads || $mustzero{$n} || TBNodeType($n) eq "garcia")) { # XXX Garcia hack print "Moving $n to $reloadpid/$pendingeid.\n"; diff --git a/tbsetup/os_load.in b/tbsetup/os_load.in index f29a018d34ad89c6fb97250c45b1246e2fed54b6..b152c7d40f58aa0997f893d508cc1ec7a5c8cbf5 100755 --- a/tbsetup/os_load.in +++ b/tbsetup/os_load.in @@ -203,11 +203,13 @@ if (defined($options{"m"})) { } } -# VIRTNODE HACK: Virtual nodes are special. Do not reload! +# +# Weed out non-imageable nodes (e.g., virtnodes, emotes, etc.) +# my @temp = (); foreach my $node ( @nodes ) { - if (TBIsNodeVirtual($node)) { - print "*** reload ($node): Skipping virtual node.\n"; + if (!TBIsNodeImageable($node)) { + print "*** reload ($node): cannot image node, skipped.\n"; next; } push(@temp, $node); diff --git a/tbsetup/reload_daemon.in b/tbsetup/reload_daemon.in index 64df1f1ffba82e8681bab0a89ec5eeba7354063d..6d206045e868047ac0ada8dba4be749d3f5aaf44 100644 --- a/tbsetup/reload_daemon.in +++ b/tbsetup/reload_daemon.in @@ -234,7 +234,7 @@ while (1) { my $CLASSCLAUSE = "(n.class='pc' or n.class='pct')"; $query_result = - DBQueryWarn("select a.node_id,b.pid,b.eid,b.mustwipe ". + DBQueryWarn("select a.node_id,b.pid,b.eid,b.mustwipe,n.imageable ". "from reserved as b ". "left join nodes as a on a.node_id=b.node_id ". "left join last_reservation as l on l.node_id=a.node_id ". @@ -262,14 +262,33 @@ while (1) { $pid = $hrow{'pid'}; $eid = $hrow{'eid'}; $mustwipe = $hrow{'mustwipe'}; + $imageable = $hrow{'imageable'}; + + # XXX Garcia Hack + if (!$imageable && TBNodeType($node) eq "garcia") { + $imageable = 1; + } + # XXX End Garcia Hack + + # + # If any non-imageable nodes made it this far, just free them now + # + if (!$imageable) { + print "Skipping non-imageable node $node\n"; + freefromreloading($node); + next; + } if ($pid eq $RELOADPID && $eid eq $PENDINGEID) { push(@pending_list, [$node,$mustwipe]); } else { push(@other_list, [$node,$mustwipe]); } } - my $nodes = join(" ", map { $_->[0] } @pending_list, @other_list); + if (!$nodes) { + next; + } + print "Trying to reload $nodes at ".`date`; # @@ -422,7 +441,7 @@ while (1) { # # This should not fail, but it does when the DB gets busy. # - notify("$os_load failed on $nodelist. ". + notify("$os_load $os_load_flags failed on $nodelist. ". "That is not supposed to happen.\n". "Attempting to recover from this unfortunate ". "situation!\n"); @@ -486,7 +505,7 @@ sub freefromreloading($) { DBQueryFatal("delete from current_reloads where node_id='$node'"); my ($pid,$eid); NodeidToExp($node,\$pid,\$eid); - if (($pid eq NODERELOADING_PID) && ($eid eq NODERELOADING_EID)) { + if ($pid eq $RELOADPID && ($eid eq $RELOADEID || $eid eq $PENDINGEID)) { DBQueryFatal("delete from scheduled_reloads ". "where node_id='$node'"); DBQueryFatal("delete from reserved where node_id='$node'");