Commit c07def92 authored by Leigh Stoller's avatar Leigh Stoller

More Logfile changes. For protogeni we want store for a short time,

the metadata even if there is nothing in the logfile. Mostly so that
the URL link works and we can get the header info if needed.

Also add slice_urn and slice_idx to the metadata so we find all the
logs associated with a slice.

Fixes.
parent c351215e
......@@ -309,26 +309,41 @@ sub Store($)
$self->Close();
#
# Use first two letters of the id for the subdir.
# Well, what if we have metadata but the logfile is empty? The
# metadata is still interesting in some situations, but rather
# then compress a null file and take an inode, just set the
# filename to null. This currently happens from the protogeni API.
# If the size of the logfiles table gets out of control, we can
# revisit this, but I think we just need to age out old ones
# on a regular basis.
#
my $dir = lc(substr($logid, 0, 2));
$newname = "$newname/$dir/${logid}.gz";
if (-e $newname) {
print STDERR "Logfile::Store ($logid) - $newname exists\n";
return -1;
if (-e $filename && -s $filename) {
#
# Use first two letters of the id for the subdir.
#
my $dir = lc(substr($logid, 0, 2));
$newname = "$newname/$dir/${logid}.gz";
if (-e $newname) {
print STDERR "Logfile::Store ($logid) - $newname exists\n";
return -1;
}
my $output = emutil::ExecQuiet("$GZIP -c $filename > $newname");
if ($?) {
SENDMAIL($TBOPS, "Logfile Store Error",
"Failed to store $filename to $newname\n\n".
"-----------------\n".
"$output\n", $TBOPS);
return -1
}
$newname = "'" . $newname . "'";
}
my $output = emutil::ExecQuiet("$GZIP -c $filename > $newname");
if ($?) {
SENDMAIL($TBOPS, "Logfile Store Error",
"Failed to store $filename to $newname\n\n".
"-----------------\n".
"$output\n", $TBOPS);
return -1
else {
$newname = "NULL";
}
unlink($filename);
DBQueryWarn("update logfiles set ".
" stored=1,compressed=1,filename='$newname' ".
" stored=1,compressed=1,filename=$newname ".
"where logid='$logid'")
or return -1;
......
......@@ -263,6 +263,7 @@ sub ListResources()
my $xml = undef;
if ($slice_urn) {
main::AddLogfileMetaData("slice_urn", $slice_urn);
# If $slice_urn is defined, this turns into a Resolve call. We
# need to resolve twice: once to get the sliver urn from the
......@@ -895,6 +896,10 @@ sub Update
if (GeniResponse::IsResponse($cred));
my ($slice, $aggregate) = GeniCMV2::Credential2SliceAggregate($cred);
if (defined($slice)) {
main::AddLogfileMetaData("slice_urn", $slice_urn);
main::AddLogfileMetaData("slice_idx", $slice->idx());
}
# The URN list must be either empty or contain the slice URN.
if (scalar(@urns) > 1 ||
......@@ -977,6 +982,7 @@ sub AllocateTicket
if (GeniResponse::IsResponse($combined)) {
return $combined;
}
my $args = {
'slice_urn' => $slice_urn,
'ticket' => $ticketStr,
......
This diff is collapsed.
This diff is collapsed.
......@@ -118,6 +118,12 @@ INSERT INTO sitevariables VALUES ('protogeni/default_osname','','','The default
INSERT INTO sitevariables VALUES ('images/root_password',NULL,'','The encryption hash of the root password to use in the MFSs.',0);
INSERT INTO sitevariables VALUES ('protogeni/idlecheck',NULL,'0','When set, do idle checks and send email about idle slices.',0);
INSERT INTO sitevariables VALUES ('protogeni/idlecheck_terminate',NULL,'0','When set, do idle checks and terminate idle slices after email warning.',0);
INSERT INTO sitevariables VALUES ('protogeni/wrapper_sa_debug_level',NULL,'0','When set, send debugging email for SA wrapper calls',0);
INSERT INTO sitevariables VALUES ('protogeni/wrapper_ch_debug_level',NULL,'0','When set, send debugging email for CH wrapper calls',0);
INSERT INTO sitevariables VALUES ('protogeni/wrapper_cm_debug_level',NULL,'1','When set, send debugging email for CM wrapper calls',0);
INSERT INTO sitevariables VALUES ('protogeni/wrapper_am_debug_level',NULL,'1','When set, send debugging email for AM wrapper calls',0);
INSERT INTO sitevariables VALUES ('protogeni/wrapper_debug_sendlog',NULL,'1','When set, wrapper debugging email will send log files in addition to the metadata',0);
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
......
#
# Add a bunch of sitevars for protogeni wrapper debugging.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBQueryFatal("INSERT INTO sitevariables VALUES ".
" ('protogeni/wrapper_sa_debug_level',NULL,'0', ".
" 'When set, send debugging email for SA wrapper calls',0)")
if (!TBSiteVarExists("protogeni/wrapper_sa_debug_level"));
DBQueryFatal("INSERT INTO sitevariables VALUES ".
" ('protogeni/wrapper_ch_debug_level',NULL,'0', ".
" 'When set, send debugging email for CH wrapper calls',0)")
if (!TBSiteVarExists("protogeni/wrapper_ch_debug_level"));
DBQueryFatal("INSERT INTO sitevariables VALUES ".
" ('protogeni/wrapper_cm_debug_level',NULL,'1', ".
" 'When set, send debugging email for CM wrapper calls',0)")
if (!TBSiteVarExists("protogeni/wrapper_cm_debug_level"));
DBQueryFatal("INSERT INTO sitevariables VALUES ".
" ('protogeni/wrapper_am_debug_level',NULL,'1', ".
" 'When set, send debugging email for AM wrapper calls',0)")
if (!TBSiteVarExists("protogeni/wrapper_am_debug_level"));
DBQueryFatal("INSERT INTO sitevariables VALUES ".
" ('protogeni/wrapper_debug_sendlog',NULL,'1', ".
" 'When set, wrapper debugging email will send log files ".
"in addition to the metadata',0)")
if (!TBSiteVarExists("protogeni/wrapper_debug_sendlog"));
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
......@@ -303,7 +303,8 @@ sub AuditAbort()
# This should be okay; the process will keep writing to it,
# but will be deleted once the process ends and its closed.
#
unlink($logfile);
unlink($logfile)
if (!$savelog);
undef($logfile);
}
delete @ENV{'TBAUDITLOG', 'TBAUDITON'};
......
......@@ -146,9 +146,12 @@ if (!$isopen) {
printf("%-15s %s\n", "$key:", $val);
}
print "\n";
print "---------------------\n";
print "----------------------------------\n";
}
if ($logfile->compressed()) {
if (!defined($logname)) {
print STDOUT "Log file has no content; this is not an error.\n";
}
elsif ($logfile->compressed()) {
system("$GUNZIP -c $logname");
}
else {
......
......@@ -39,8 +39,7 @@ if (! isset($logfile)) {
PAGEARGERROR("Must provide either a logfile ID");
}
# Check permission in the backend. The user is logged in, so its safe enough
# to pass it through.
# Check permission in the backend.
$logfileid = $logfile->logid();
#
......
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