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 b60f8eea authored by Mac Newbold's avatar Mac Newbold

Fix autoreloading disks when they get freed.

parent 6bb7d228
......@@ -70,7 +70,7 @@ foreach my $n (@node_names) {
&& $error++);
if ( ($sth->num_rows()) > 0) {
my @reload;
print STDERR "Adding reloads for $n to the list.\n";
print "Adding reloads for $n to the list.\n";
my $i = 0;
my $max = $sth->num_rows();
while ( $i < $max ) {
......@@ -88,13 +88,6 @@ foreach my $n (@node_names) {
}
}
# Change reservation (don't delete or we'll get races)
$cmd = "update reserved set pid='$reloadpid',eid='$reloadeid' where ".
"node_id='$n'";
$sth = $dbh->query($cmd)
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++ && next);
} else {
# No reloads to be done, so really free the node
print "Releasing node '$n'...";
......@@ -140,4 +133,24 @@ foreach $reload ( keys(%reloads)) {
print STDERR "Reload for @list complete.\n";
}
print "Locking tables.\n";
$cmd = "lock tables nodes read, node_types read, reloads read, ".
"interfaces write, reserved write";
$sth = $dbh->query($cmd)
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
foreach $n (keys(%reloads)) {
# Change reservation (don't delete or we'll get races)
$cmd = "update reserved set pid='$reloadpid',eid='$reloadeid' where ".
"node_id='$n'";
$sth = $dbh->query($cmd)
|| (print "Failed Command:\n$cmd\nError string is:".$dbh->errstr."\n"
&& $error++ && next);
}
print "Unlocking tables.\n";
$cmd = "unlock tables";
$sth = $dbh->query($cmd)
|| die("Locking error:\n$cmd\nError string is:".$dbh->errstr."\n");
exit($error);
......@@ -74,7 +74,7 @@ my @nodes = @ARGV;
#
if ($UID != 0) {
($name) = getpwuid($UID)
or die "$UID not in passwd file";
or die "$UID not in passwd file\n";
$db_result = $DB->query("select admin from users where uid='$name'");
@row = $db_result->fetchrow_array();
......@@ -83,13 +83,6 @@ if ($UID != 0) {
}
}
#
# Mere Users cannot load the entire disk.
#
if ($mereuser && !$imagepart) {
die("Only can root or TB administrators can reload the entire disk");
}
#
# Check to make sure that mere user is allowed to muck with nodes
#
......@@ -101,7 +94,7 @@ if ($mereuser) {
"reserved.node_id='$node' ".
"where proj_memb.uid='$name'");
if ($db_result->numrows < 1) {
die("You do not have permission to load images on $node");
die("You do not have permission to load images on $node\n");
}
}
}
......@@ -110,17 +103,17 @@ if ($mereuser) {
# We only support 0 or 4 right now.
#
if ($imagepart != 0 && $imagepart != 4) {
die("Only the entire disk or partition 4 can be loaded.");
die("Only the entire disk or partition 4 can be loaded.\n");
}
#
# The image has to be accessible, and it must reside in the right places.
#
if (! -e $imagepath) {
die("Cannot access $imagepath.");
die("Cannot access $imagepath.\n");
}
if (! -f $imagepath) {
die("$imagepath is not a plain file.");
die("$imagepath is not a plain file.\n");
}
#
......@@ -145,7 +138,7 @@ elsif (index($imagepath, "/proj/") >= 0) {
$cmdline = "${PLASTICADDR}:$imagepath $diskpart";
}
else {
die("Your image must reside in $TB/images or /proj");
die("Your image must reside in $TB/images or /proj\n");
}
#
......
......@@ -20,7 +20,7 @@ use English;
#
# Configure variables
#
my $TB = "@prefix@";
my $TB = "@prefix@/bin";
my $DBNAME = "@TBDBNAME@";
my $rsh = "sshtb -q";
......@@ -66,7 +66,7 @@ my @nodes = @ARGV;
#
if ($UID != 0) {
($name) = getpwuid($UID)
or die "$UID not in passwd file";
or die "$UID not in passwd file\n";
$db_result = $DB->query("select admin from users where uid='$name'");
@row = $db_result->fetchrow_array();
......@@ -102,17 +102,17 @@ if ($mereuser) {
# We only support 0 or 4 right now.
#
if ($imagepart != 0 && $imagepart != 4) {
die("Only the entire disk or partition 4 can be loaded.");
die("Only the entire disk or partition 4 can be loaded.\n");
}
#
# The image has to be accessible, and it must reside in the right places.
#
if (! -e $imagepath) {
die("Cannot access $imagepath.");
die("Cannot access $imagepath.\n");
}
if (! -f $imagepath) {
die("$imagepath is not a plain file.");
die("$imagepath is not a plain file.\n");
}
#
......@@ -157,6 +157,16 @@ foreach my $node (@nodes) {
next;
}
$sth = $DB->query("select * from nodes where node_id='$pc'");
if ($sth == 0) {
die("Database lookup failed (reserved). Aborted...\n");
}
if ($sth->num_rows() != 1) {
print STDERR "Node $pc doesn't exist. Skipping $pc.\n";
next;
}
# Always put it in the reloads table so TMCD knows to free it.
print STDERR "Scheduling reload for $pc:\n".
"Load OS $imageid to partition $imagepart from $imagepath\n";
......@@ -169,8 +179,7 @@ foreach my $node (@nodes) {
}
print STDERR "Checking if $pc is reserved...";
$sth = $DB->query("select * from reserved ".
"where node_id='$pc'");
$sth = $DB->query("select * from reserved where node_id='$pc'");
if ($sth == 0) {
die("Database lookup failed (reserved). Aborted...\n");
}
......
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