Commit 26b318a2 authored by Leigh Stoller's avatar Leigh Stoller

A hack for Mike. Add a node_history table to store all moves in and

out of the reserved table. Mostly this happens in nfree and nalloc,
but there a couple of other moves, in libdb and in the reload daemon.
The uid and experiment are stored, long with a timestamp.
parent 422a62cd
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -203,6 +203,10 @@ use vars qw(@ISA @EXPORT);
TBDB_SECLEVEL_ORANGE TBDB_SECLEVEL_RED
TBExptSetPanicBit TBExptGetPanicBit TBExptClearPanicBit
TB_NODEHISTORY_OP_FREE TB_NODEHISTORY_OP_ALLOC TB_NODEHISTORY_OP_MOVE
TBSetNodeHistory
);
# Must come after package declaration!
......@@ -453,6 +457,11 @@ sub TB_NODELOGTYPE_MISC { "misc"; }
sub TB_NODELOGTYPES() { ( TB_NODELOGTYPE_MISC ) ; }
sub TB_DEFAULT_NODELOGTYPE() { TB_NODELOGTYPE_MISC; }
# Node History Stuff.
sub TB_NODEHISTORY_OP_FREE { "free"; }
sub TB_NODEHISTORY_OP_ALLOC { "alloc"; }
sub TB_NODEHISTORY_OP_MOVE { "move"; }
# Reload Types.
sub TB_RELOADTYPE_NETDISK() { "netdisk"; }
sub TB_RELOADTYPE_FRISBEE() { "frisbee"; }
......@@ -2667,6 +2676,8 @@ sub MarkPhysNodeDown($)
"where node_id='$pnode'");
DBQueryFatal("unlock tables");
TBSetNodeHistory($pnode, TB_NODEHISTORY_OP_MOVE, $UID, $pid, $eid);
}
#
......@@ -4728,6 +4739,25 @@ sub TBGetUniqueIndex($)
return $curidx;
}
sub TBSetNodeHistory($$$$$)
{
my ($nodeid, $op, $uid, $pid, $eid) = @_;
my $exptidx;
if (!TBExptIDX($pid, $eid, \$exptidx)) {
print "*** WARNING: No such experiment $pid/$eid!\n";
return 0;
}
if ($uid =~ /^[0-9]+$/) {
$uid = ($uid == 0 ? "root" : MapNumericUID($uid));
}
return DBQueryWarn("insert into node_history set ".
" history_id=0, node_id='$nodeid', op='$op', ".
" uid='$uid', stamp=UNIX_TIMESTAMP(now()), ".
" exptidx=$exptidx");
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -76,6 +76,7 @@ my $noalloc = 0;
my @vals = ();
my @nodes = ();
my @need_consetup = 0;
my @need_history = ();
TBDebugTimeStamp("nalloc started");
#
......@@ -153,6 +154,10 @@ foreach my $n (@node_names) {
next;
}
}
else {
# Freshly allocated nodes need a history entry.
push(@need_history, $n);
}
#
# Add info the list of nodes to reserve; done in a single query below.
......@@ -183,6 +188,8 @@ TBDebugTimeStamp("nalloc allocated all nodes");
DBQueryFatal("unlock tables");
TBDebugTimeStamp("nalloc unlocked tables");
# Okay, not safe to do this
# Update node_activity table; no need to do this with tables locked.
if (!$error && (!$noalloc || $partial) && @nodes) {
print "Resetting node activity\n"
......@@ -193,6 +200,10 @@ if (!$error && (!$noalloc || $partial) && @nodes) {
"where " . join(" or ",map("node_id='$_'", @nodes)));
TBDebugTimeStamp("nalloc updated node_activity table");
foreach my $n (@need_history) {
TBSetNodeHistory($n, TB_NODEHISTORY_OP_ALLOC, $UID, $pid, $eid);
}
}
# Now setup consoles if needed.
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -328,6 +328,9 @@ foreach my $n (@freed_nodes) {
"vname='$n' where node_id='$n'")
|| $error++;
TBSetNodeHistory($n, TB_NODEHISTORY_OP_MOVE, $UID,
$next_pid, $next_eid);
DBQueryWarn("delete from next_reserve where node_id='$n'")
|| $error++;
......@@ -352,6 +355,9 @@ foreach my $n (@freed_nodes) {
DBQueryWarn("update reserved set pid='$reloadpid',eid='$pendingeid',".
"vname='$n' where node_id='$n'") || $error++;
TBSetNodeHistory($n, TB_NODEHISTORY_OP_MOVE, $UID,
$reloadpid, $pendingeid);
# This little sillyness is for disk reloading.
# Kill the last reservation since this path is special.
DBQueryWarn("delete from last_reservation where node_id='$n'") ||
......@@ -373,6 +379,8 @@ foreach my $n (@freed_nodes) {
print "Releasing node '$n' ... ";
if (DBQueryWarn("delete from reserved where node_id='$n'")) {
print "Succeeded.\n";
TBSetNodeHistory($n, TB_NODEHISTORY_OP_FREE, $UID, $pid, $eid);
}
else {
print "Failed!\n";
......
......@@ -905,6 +905,21 @@ CREATE TABLE node_features (
PRIMARY KEY (node_id,feature)
) TYPE=MyISAM;
--
-- Table structure for table `node_history`
--
CREATE TABLE node_history (
history_id int(10) unsigned NOT NULL auto_increment,
node_id varchar(32) NOT NULL default '',
op enum('alloc','free','move') NOT NULL default 'alloc',
uid varchar(8) NOT NULL default '',
exptidx int(10) unsigned default NULL,
stamp int(10) unsigned default NULL,
PRIMARY KEY (history_id),
KEY node_id (node_id)
) TYPE=MyISAM;
--
-- Table structure for table `node_hostkeys`
--
......
......@@ -2318,3 +2318,18 @@ last_net_act,last_cpu_act,last_ext_act);
alter table switch_stacks drop primary key;
alter table switch_stacks add index (node_id);
alter table switch_stacks add column (is_primary tinyint(1) not null default '1');
1.301: Add node history table at Mike's request to track what
experiments are assigned to over time.
CREATE TABLE node_history (
history_id int(10) unsigned NOT NULL auto_increment,
node_id varchar(32) NOT NULL default '',
op enum('alloc','free','move') NOT NULL default 'alloc',
uid varchar(8) NOT NULL default '',
exptidx int(10) unsigned default NULL,
stamp int(10) unsigned default NULL,
PRIMARY KEY (history_id),
KEY node_id (node_id)
) TYPE=MyISAM;
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -312,6 +312,11 @@ while (1) {
next;
} else {
print "Pending nodes moved to $RELOADEID at ".`date`;
foreach my $n (@pending_list) {
TBSetNodeHistory($n, TB_NODEHISTORY_OP_MOVE, $UID,
$RELOADPID, $RELOADEID);
}
}
# It is now safe to clear this.
@retry_list = ();
......
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