Commit 9de5eac3 authored by Leigh Stoller's avatar Leigh Stoller

Quickie locking for Kirk, to serialize assign for tutorial.

parent 660b8e45
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -95,6 +95,8 @@ DBQueryFatal("delete from login");
# Clear the pool daemon lock.
#
DBQueryFatal("replace into emulab_locks set name='pool_daemon',value='0'");
# And other locks.
DBQueryFatal("update emulab_locks set value='0'");
#
# Check for experiments stuck in transition.
......
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -258,4 +258,31 @@ sub IsShutDown()
return ($value ? 1 : 0);
}
#
# Lock and Unlock.
#
sub EmulabLock($)
{
my ($name) = @_;
my $query_result =
DBQueryWarn("update emulab_locks set value=1 " .
"where name='$name' and value=0");
if (! $query_result || $query_result->affectedrows == 0) {
return -1;
}
return 0;
}
sub EmulabUnlock($)
{
my ($name) = @_;
DBQueryWarn("update emulab_locks set value=0 where name='$name'")
or return -1;
return 0;
}
1;
......@@ -95,6 +95,7 @@ my $clear = 0;
my $warnings = 0;
my $maxrun = 3; # Maximum number of times we run assign.
my $gotlock = 0;
my $seriallock = 0;
my $userspec = 0;
my $usecontrol = 0;
my $use_old_ptopgen = 0;
......@@ -124,6 +125,7 @@ use libtestbed;
use libtblog;
use libvtop;
use libadminctrl;
use libEmulab;
use User;
use EmulabFeatures;
......@@ -436,7 +438,18 @@ sub AssignLoop()
sleep(10);
}
}
# Hack for Kirk.
if (!($impotent || $regression) && $MAINSITE && $pid eq "PNWorkshop") {
while (1) {
if (libEmulab::EmulabLock("mapperlock") == 0) {
$seriallock = 1;
last;
}
chat("Waiting for mapper lock ...\n");
sleep(5);
}
}
#
# RunAssign returns 0 if successful.
# returns -1 if failure, but assign says to stop trying.
......@@ -451,6 +464,10 @@ sub AssignLoop()
"where name='pool_daemon'");
$gotlock = 0;
}
if ($seriallock) {
libEmulab::EmulabUnlock("mapperlock");
$seriallock = 0;
}
# Success!
last
......@@ -932,6 +949,10 @@ END {
"where name='pool_daemon'");
$gotlock = 0;
}
if ($seriallock) {
libEmulab::EmulabUnlock("mapperlock");
$seriallock = 0;
}
if ($exitcode && $exitcode != $WRAPPER_FAILED) {
$exitcode = $WRAPPER_FAILED|$WRAPPER_FAILED_FATALLY;
......
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