Commit 544db994 authored by Leigh B. Stoller's avatar Leigh B. Stoller

More archive support cleanup. Been messing with the NFS tracing code

but that stuff is still not totally hooked in yet.
parent e8683096
...@@ -72,7 +72,7 @@ if (@ARGV < 3) { ...@@ -72,7 +72,7 @@ if (@ARGV < 3) {
usage(); usage();
} }
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 2;
} }
if (defined($options{"f"})) { if (defined($options{"f"})) {
$force = 1; $force = 1;
...@@ -115,17 +115,8 @@ if (! TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_UPDATE)) { ...@@ -115,17 +115,8 @@ if (! TBExptAccessCheck($UID, $pid, $eid, TB_EXPT_UPDATE)) {
fatal("You do not have permission to control the archive for $pid/$eid!"); fatal("You do not have permission to control the archive for $pid/$eid!");
} }
#
# Do not allow an archive system to be controlled if the experiment is not
# active or swapped. Will probably be changed later.
#
if ($expstate ne EXPTSTATE_ACTIVE &&
$expstate ne EXPTSTATE_SWAPPED) {
fatal("Experiment $pid/$eid must be active or swapped!");
}
# Temporary # Temporary
libArchive::setdebug(2); libArchive::setdebug($debug);
# Do not audit this operation. # Do not audit this operation.
if ($action eq "checktag") { if ($action eq "checktag") {
...@@ -146,6 +137,15 @@ if ($action eq "checktag") { ...@@ -146,6 +137,15 @@ if ($action eq "checktag") {
exit(($unique ? 0 : 1)); exit(($unique ? 0 : 1));
} }
#
# Do not allow an archive system to be controlled if the experiment is not
# active or swapped. Will probably be changed later.
#
if ($expstate ne EXPTSTATE_ACTIVE &&
$expstate ne EXPTSTATE_SWAPPED) {
fatal("Experiment $pid/$eid must be active or swapped!");
}
# #
# Allow the user to force a commit of the archive. # Allow the user to force a commit of the archive.
# #
...@@ -187,7 +187,7 @@ if ($action eq "commit") { ...@@ -187,7 +187,7 @@ if ($action eq "commit") {
} }
} }
if ($NFSTRACESUPPORT) { if (0 && $NFSTRACESUPPORT) {
# #
# This program asks the nodes for the trace results. # This program asks the nodes for the trace results.
# #
...@@ -357,6 +357,8 @@ elsif ($action eq "list" || ...@@ -357,6 +357,8 @@ elsif ($action eq "list" ||
"LEFT JOIN accessed_files as af on af.idx=fr.fileidx ". "LEFT JOIN accessed_files as af on af.idx=fr.fileidx ".
"WHERE fr.rsrcidx=$rsrcidx and fr.type!='l'"); "WHERE fr.rsrcidx=$rsrcidx and fr.type!='l'");
while (my ($fn) = $query_result->fetchrow_array()) { while (my ($fn) = $query_result->fetchrow_array()) {
#print "Accessed: $fn\n";
if ($fn =~ /^\/share/ || if ($fn =~ /^\/share/ ||
$fn =~ /\/tbdata\// || $fn =~ /\/tbdata\// ||
$fn =~ /^<u:/) { $fn =~ /^<u:/) {
......
...@@ -995,10 +995,10 @@ sub ArchiveCheckout($$;$$$) ...@@ -995,10 +995,10 @@ sub ArchiveCheckout($$;$$$)
# I intend this to be run only when an experiment is terminated. # I intend this to be run only when an experiment is terminated.
# No need to have two copies. # No need to have two copies.
# #
sub ArchiveArchive($$) sub ArchiveArchive($)
{ {
my ($archive_idx, $dirpath) = @_; my ($archive_idx) = @_;
my $target = "$dirpath/Archive"; my $target = "$ARCHIVEDIR/Archive/$archive_idx";
# #
# See if the archive exists and if it does, get the pathname to it. # See if the archive exists and if it does, get the pathname to it.
...@@ -1052,7 +1052,6 @@ sub ArchiveArchive($$) ...@@ -1052,7 +1052,6 @@ sub ArchiveArchive($$)
return -1; return -1;
} }
} }
# #
# Tar up the whole thing and move it across. # Tar up the whole thing and move it across.
# #
...@@ -1978,7 +1977,7 @@ sub TBArchiveExperimentArchive($$) ...@@ -1978,7 +1977,7 @@ sub TBArchiveExperimentArchive($$)
return -1 return -1
if ($rval < 0); if ($rval < 0);
return ArchiveArchive($archive_idx, TBExptLogDir($pid, $eid)); return ArchiveArchive($archive_idx);
} }
# #
...@@ -2097,9 +2096,11 @@ sub TBIsTaqUnique($$$$) ...@@ -2097,9 +2096,11 @@ sub TBIsTaqUnique($$$$)
# #
sub TBListExperimentArchive($$$;$$) sub TBListExperimentArchive($$$;$$)
{ {
my ($pid, $eid, $prval, $tag, $subdir) = @_; my ($pid, $eid, $prval, $tag, $root, $subdir) = @_;
my ($archive_idx, $view); my ($archive_idx, $view);
my @filelist = (); my @filelist = ();
my $sourcepoint = "";
my $expstate = ExpState($pid, $eid);
@$prval = @filelist; @$prval = @filelist;
return 0 return 0
...@@ -2111,7 +2112,16 @@ sub TBListExperimentArchive($$$;$$) ...@@ -2111,7 +2112,16 @@ sub TBListExperimentArchive($$$;$$)
return -1 return -1
if ($rval < 0); if ($rval < 0);
my $sourcepoint = (defined($tag) ? "tags/$tag" : "trunk"); # If the experiment is active, use the savepoint.
if (defined($tag)) {
$sourcepoint = "tags/$tag";
}
elsif ($expstate && $expstate eq EXPTSTATE_ACTIVE()) {
$sourcepoint = "savepoint";
}
else {
$sourcepoint = "trunk";
}
$sourcepoint = "$sourcepoint/$subdir" $sourcepoint = "$sourcepoint/$subdir"
if (defined($subdir)); if (defined($subdir));
......
...@@ -16,34 +16,32 @@ $isadmin = ISADMIN($uid); ...@@ -16,34 +16,32 @@ $isadmin = ISADMIN($uid);
# #
# Verify page arguments. # Verify page arguments.
# #
if (!isset($pid) || # An experiment idx.
strcmp($pid, "") == 0) { if (! isset($exptidx) || $exptidx == "") {
USERERROR("You must provide a Project ID.", 1); USERERROR("Must supply an experiment index!", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID.");
} }
if (!TBvalid_eid($eid)) { if (!TBvalid_integer($exptidx)) {
PAGEARGERROR("Invalid experiment ID."); USERERROR("Invalid characters in $exptidx!", 1);
} }
$exptidx = TBExptIndex($pid, $eid);
if ($exptidx < 0) { #
TBERROR("Could not map $pid/$eid to ID!", 1); # We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
} }
if (!TBExptGroup($pid, $eid, $gid)) { if (!TBCurrentExperiment($exptidx)) {
TBERROR("Could not get experiment gid for $pid/$eid!", 1); USERERROR("Experiment index $exptidx is not a current experiment!", 1);
} }
if (!$isadmin &&
if (!$isadmin) { !TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) { USERERROR("You do not have permission to view missing files for ".
USERERROR("You do not have permission to view missing files for ". "archive in $pid/$gid ($exptidx)!", 1);
"experiment $pid/$eid!", 1);
}
} }
# #
...@@ -65,7 +63,7 @@ if (isset($movesome)) { ...@@ -65,7 +63,7 @@ if (isset($movesome)) {
"webarchive_control addtoarchive $pid $eid $fileargs", "webarchive_control addtoarchive $pid $eid $fileargs",
SUEXEC_ACTION_DUPDIE); SUEXEC_ACTION_DUPDIE);
header("Location: archive_missing.php3?pid=$pid&eid=$eid"); header("Location: archive_missing.php3?exptidx=$exptidx");
return; return;
} }
...@@ -131,7 +129,7 @@ if (count($suexec_output_array)) { ...@@ -131,7 +129,7 @@ if (count($suexec_output_array)) {
echo "</b><br><br>"; echo "</b><br><br>";
echo "<table border=1>\n"; echo "<table border=1>\n";
echo "<form action='archive_missing.php3?pid=$pid&eid=$eid' echo "<form action='archive_missing.php3?exptidx=$exptidx'
onsubmit=\"return false;\" onsubmit=\"return false;\"
name=form1 method=post>\n"; name=form1 method=post>\n";
echo "<input type=hidden name=movesome value=Submit>\n"; echo "<input type=hidden name=movesome value=Submit>\n";
......
...@@ -16,30 +16,42 @@ $isadmin = ISADMIN($uid); ...@@ -16,30 +16,42 @@ $isadmin = ISADMIN($uid);
# #
# Verify page arguments. # Verify page arguments.
# #
if (!isset($pid) || if (! isset($exptidx) || $exptidx == "") {
strcmp($pid, "") == 0) { USERERROR("Must supply an experiment to view!", 1);
USERERROR("You must provide a Project ID.", 1);
} }
if (!isset($eid) || if (!TBvalid_integer($exptidx)) {
strcmp($eid, "") == 0) { USERERROR("Invalid characters in $exptidx!", 1);
USERERROR("You must provide an Experiment ID.", 1);
} }
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID."); #
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
} }
if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid experiment ID."); if (!$isadmin &&
!TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view tags for ".
"archive in $pid/$gid ($exptidx)!", 1);
}
if (!TBCurrentExperiment($exptidx)) {
USERERROR("Experiment index $exptidx is not a current experiment!", 1);
} }
function SPITFORM($formfields, $errors) function SPITFORM($formfields, $errors)
{ {
global $isadmin, $pid, $eid, $TBDB_ARCHIVE_TAGLEN; global $isadmin, $exptidx, $TBDB_ARCHIVE_TAGLEN;
# #
# Standard Testbed Header # Standard Testbed Header
# #
PAGEHEADER("Commit/Tag archive for experiment $pid/$eid"); PAGEHEADER("Commit/Tag archive for experiment $exptidx");
echo "<center> echo "<center>
Commit/Tag Archive Commit/Tag Archive
...@@ -68,7 +80,7 @@ function SPITFORM($formfields, $errors) ...@@ -68,7 +80,7 @@ function SPITFORM($formfields, $errors)
} }
echo "<table align=center border=1> echo "<table align=center border=1>
<form action=archive_tag.php3?pid=$pid&eid=$eid method=post>\n"; <form action=archive_tag.php3?exptidx=$exptidx method=post>\n";
echo "<tr> echo "<tr>
<td align=center> <td align=center>
...@@ -196,10 +208,6 @@ if (count($errors)) { ...@@ -196,10 +208,6 @@ if (count($errors)) {
return; return;
} }
if (!TBExptGroup($pid, $eid, $gid)) {
TBERROR("Could not get experiment gid for $pid/$eid!", 1);
}
# #
# First lets make sure the tag is unique. # First lets make sure the tag is unique.
# #
...@@ -226,5 +234,5 @@ SUEXEC($uid, "$pid,$gid", ...@@ -226,5 +234,5 @@ SUEXEC($uid, "$pid,$gid",
"webarchive_control $tagarg $message commit $pid $eid", "webarchive_control $tagarg $message commit $pid $eid",
SUEXEC_ACTION_DIE); SUEXEC_ACTION_DIE);
header("Location: archive_view.php3?pid=$pid&eid=$eid"); header("Location: archive_view.php3/$exptidx/?exptidx=$exptidx");
?> ?>
...@@ -24,53 +24,58 @@ if (!isset($records) || !strcmp($records, "")) { ...@@ -24,53 +24,58 @@ if (!isset($records) || !strcmp($records, "")) {
$records = 100; $records = 100;
} }
if (! isset($which) || $which == "") { # An experiment idx.
USERERROR("Must supply an experiment to view!", 1); if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment index!", 1);
} }
if (!TBvalid_integer($which)) { if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $which!", 1); USERERROR("Invalid characters in $exptidx!", 1);
} }
# #
# We get an index. Must map that to a pid/eid to do the permission # We get an index. Must map that to a pid/gid to do a group level permission
# check, and note that it might not be an current experiment. Not # check, since it might not be an current experiment.
# sure I like this so I am not going to permit it for mere users
# just yet.
# #
$query_result = unset($pid);
DBQueryFatal("select pid,eid from experiments where idx='$which'"); unset($eid);
if (mysql_num_rows($query_result) == 0) { unset($gid);
USERERROR("No such experiment index $which!", 1); if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
} }
$row = mysql_fetch_array($query_result);
$pid = $row["pid"];
$eid = $row["eid"];
if (!$isadmin) { if (!$isadmin &&
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) { !TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
USERERROR("You do not have permission to view tags for ". USERERROR("You do not have permission to view tags for ".
"experiment $pid/$eid ($which)!", 1); "archive in $pid/$gid ($exptidx)!", 1);
} }
if (TBCurrentExperiment($exptidx)) {
echo "<center><font size=+1>".
"Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
"(<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a>) ".
"</b></font>\n";
"</center><br>";
}
else {
echo "<center><font size=+1>".
"Experiment ".
"<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a> ".
"</b></font>\n";
"</center><br>";
} }
echo "<center><font size=+1>".
"Experiment <b>".
"<a href='showproject.php3?pid=$pid'>$pid</a>/".
"<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
"(<a href='showstats.php3?showby=expt&which=$which'>$which</a>) ".
"</b></font>\n";
"</center><br>";
echo "<br>\n"; echo "<br>\n";
# #
# We need the archive index so we can find its view. # We need the archive index so we can find its view.
# #
$query_result = $query_result =
DBQueryFatal("select s.archive_idx from experiments as e ". DBQueryFatal("select s.archive_idx from experiment_stats as s ".
"left join experiment_stats as s on s.exptidx=e.idx ". "where s.exptidx='$exptidx'");
"where e.pid='$pid' and e.eid='$eid'");
if (mysql_num_rows($query_result) == 0) { if (mysql_num_rows($query_result) == 0) {
TBERROR("Could not get archive index for experiment $pid/$eid", 1); TBERROR("Could not get archive index for experiment $exptidx", 1);
} }
$row = mysql_fetch_array($query_result); $row = mysql_fetch_array($query_result);
$archive_idx = $row["archive_idx"]; $archive_idx = $row["archive_idx"];
...@@ -79,9 +84,11 @@ $archive_idx = $row["archive_idx"]; ...@@ -79,9 +84,11 @@ $archive_idx = $row["archive_idx"];
# Grab all the (commit/user) tags. # Grab all the (commit/user) tags.
# #
$query_result = $query_result =
DBQueryFatal("select * from archive_tags ". DBQueryFatal("select *,FROM_UNIXTIME(date_created) as date_created ".
"where archive_idx='$archive_idx' and view='$which' and ". " from archive_tags ".
" (tagtype='user' or tagtype='commit')"); "where archive_idx='$archive_idx' and view='$exptidx' and ".
" (tagtype='user' or tagtype='commit') ".
"order by date_created desc");
if (mysql_num_rows($query_result) == 0) { if (mysql_num_rows($query_result) == 0) {
USERERROR("No tags for experiment $pid/$eid", 1); USERERROR("No tags for experiment $pid/$eid", 1);
...@@ -90,7 +97,7 @@ if (mysql_num_rows($query_result) == 0) { ...@@ -90,7 +97,7 @@ if (mysql_num_rows($query_result) == 0) {
echo "<table align=center border=1> echo "<table align=center border=1>
<tr>"; <tr>";
echo " <th>Run</th>"; echo " <th>Run</th>";
echo " <th>Tag</th>"; echo " <th>Tag (Click to visit archive)</th>";
echo " <th>Date</th>"; echo " <th>Date</th>";
echo " <th>Description</th>"; echo " <th>Description</th>";
echo "</tr>\n"; echo "</tr>\n";
...@@ -102,11 +109,11 @@ while ($row = mysql_fetch_assoc($query_result)) { ...@@ -102,11 +109,11 @@ while ($row = mysql_fetch_assoc($query_result)) {
echo "<tr>"; echo "<tr>";
echo " <td align=center> echo " <td align=center>
<a href=beginexp_html.php3?copyid=$which:$archive_tag> <a href=beginexp_html.php3?copyid=$exptidx:$archive_tag>
<img border=0 alt=Run src=greenball.gif></a></td>"; <img border=0 alt=Run src=greenball.gif></a></td>";
echo " <td>". echo " <td>".
"<a href='cvsweb/cvswebwrap.php3/$which/history/". "<a href='archive_view.php3/$exptidx/history/".
"$archive_tag/?exptidx=$which'>$archive_tag</a>". "$archive_tag/?exptidx=$exptidx'>$archive_tag</a>".
" </td>"; " </td>";
echo " <td>$date_tagged</td>"; echo " <td>$date_tagged</td>";
......
...@@ -15,81 +15,72 @@ LOGGEDINORDIE($uid); ...@@ -15,81 +15,72 @@ LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid); $isadmin = ISADMIN($uid);
# #
# Verify page arguments. # Standard Testbed Header.
# #
if (isset($exptidx) && $exptidx != "") { PAGEHEADER("Experiment Archive ($exptidx)");
if (!TBvalid_integer($exptidx)) {
PAGEARGERROR("Invalid experiment index.");
}
PAGEHEADER("Experiment Archive ($exptidx)");
unset($pid); #
unset($eid); # Verify page arguments.
unset($gid); #
TBExptidx2PidEid($exptidx, $pid, $eid, $gid); if (! isset($exptidx) || $exptidx == "") {
USERERROR("Must supply an experiment to view!", 1);
}
if (!TBvalid_integer($exptidx)) {
USERERROR("Invalid characters in $exptidx!", 1);
}
$url = preg_replace("/archive_view/", "cvsweb/cvsweb", #
$_SERVER['REQUEST_URI']); # We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
#
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
USERERROR("No such experiment index $exptidx!", 1);
} }
else {
if (!isset($pid) ||
strcmp($pid, "") == 0) {
USERERROR("You must provide a Project ID.", 1);
}
if (!isset($eid) ||
strcmp($eid, "") == 0) {
USERERROR("You must provide an Experiment ID.", 1);
}
if (!TBvalid_pid($pid)) {
PAGEARGERROR("Invalid project ID.");
}
if (!TBvalid_eid($eid)) {
PAGEARGERROR("Invalid experiment ID.");
}
# if (!$isadmin &&
# Check to make sure this is a valid PID/EID tuple. !TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
# USERERROR("You do not have permission to view tags for ".
if (! TBValidExperiment($pid, $eid)) { "archive in $pid/$gid ($exptidx)!", 1);
USERERROR("The experiment $eid is not a valid experiment ".
"in project $pid.", 1);
}
$exptidx = TBExptIndex($pid, $eid);
if ($exptidx < 0) {
TBERROR("Could not get experiment index for $pid/$eid!", 1);
}
PAGEHEADER("Experiment Archive ($pid/$eid)");
$url = "cvsweb/cvsweb.php3/${exptidx}?exptidx=$exptidx";
} }
$current = TBCurrentExperiment($exptidx);
$url = preg_replace("/archive_view/", "cvsweb/cvsweb",
$_SERVER['REQUEST_URI']);
# This is how you get forms to align side by side across the page. # This is how you get forms to align side by side across the page.
$style = 'style="float:left; width:33%;"'; if ($current) {
$style = 'style="float:left; width:33%;"';
}
else {
$style = "";
}
echo "<center>\n"; echo "<center>\n";
echo "<font size=+1> echo "<font size=+1>
This is the Subversion archive for your experiment.<br></font>"; This is the Subversion archive for experiment $exptidx.<br></font>";