Commit 229d2bcc authored by Leigh B Stoller's avatar Leigh B Stoller

Start saving the virtual and physical state after each swapin/swapmod

so that we can do post-mortem debugging. I'm adding this so I can
track down the current snmpit failures, but might useful later too.

Sadly, mysql dump files have no table metadata so once the schema
changes, these files will become less useful if we ever want to load
them into a running DB. It would be nie to dump them in a format that
allows this, but will be a bunch more work.
parent 7818052e
......@@ -2841,6 +2841,8 @@ sub CleanLogFiles($)
}
mysystem("/bin/rm -f @delete") == 0
or return -1;
mysystem("/bin/rm -rf ${workdir}/vstate.* ${workdir}/pstate.*") == 0
or return -1;
return 0;
}
......@@ -3127,9 +3129,9 @@ sub UpdateIdleSwapTime($$)
#
# Experiment tables.
#
sub BackupVirtualState($)
sub BackupVirtualState($;$)
{
my ($self) = @_;
my ($self, $directory) = @_;
# Must be a real reference.
return -1
......@@ -3138,7 +3140,8 @@ sub BackupVirtualState($)
my $pid = $self->pid();
my $eid = $self->eid();
my $idx = $self->idx();
my $vstateDir = $self->WorkDir() . "/vstate";
my $vstateDir = (defined($directory) ?
$directory : $self->WorkDir() . "/vstate");
my $errors = 0;
if (! -e $vstateDir) {
......@@ -3238,6 +3241,84 @@ sub SaveBackupState($)
return 0;
}
#
# This data will be saved longterm in the expinfo directory. The problem
# is that mysql dump files have no table metadata, so when the schema
# changes, these files will no longer be loadable. Not that we want to
# load them, but it would be nice if the format allowed for schema changes.
# To do that will require a bunch more work. Some day ...
#
sub SaveExperimentState($)
{
my ($self) = @_;
# Must be a real reference.
return -1
if (! ref($self));
my $pid = $self->pid();
my $eid = $self->eid();
my $workdir = $self->WorkDir();
my $vstateDir = `mktemp -d $workdir/vstate.XXXXXX`;
# Untaint to avoid stupid errors
if ($vstateDir =~ /^([-\w\.\/]+)$/) {
$vstateDir = $1;
}
chmod(0777, $vstateDir)
or return -1;
$self->BackupVirtualState($vstateDir);
#
# Most of these tables are empty, so lets not burn up zillions
# of inodes for no reason.
#
foreach my $table (@virtualTables) {
my $file = "$vstateDir/$table";
unlink($file)
if (-z $file);
}
#
# Do not backup physical state if the experiment is not active.
#
if ($self->state() eq EXPTSTATE_ACTIVE) {
my $pstateDir = `mktemp -d $workdir/pstate.XXXXXX`;
# Untaint to avoid stupid errors.
if ($pstateDir =~ /^([-\w\.\/]+)$/) {
$pstateDir = $1;
}
chmod(0777, $pstateDir)
or return -1;
$self->BackupPhysicalState($pstateDir);
#
# Most of these tables are empty, so lets not burn up zillions
# of inodes for no reason.
#
opendir(DIR, $pstateDir) or
return -1;
my @files = readdir(DIR);
closedir(DIR);
foreach my $file (@files) {
$file = "$pstateDir/$file";
# Untaint to avoid stupid errors.
if ($file =~ /^([-\w\.\/]+)$/) {
$file = $1;
}
unlink($file)
if (-z $file);
}
}
return 0;
}
sub RemovePhysicalState($;$)
{
my ($self, $purge) = @_;
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -725,9 +725,15 @@ if (defined($logname)) {
}
#
# Save a copy of the files for testbed information gathering (long term).
# Save the final experiment state so that we get a running record of
# the state on disk, for post-mortem debugging. This will get copied
# to the expinfo directory in the next line.
#
$experiment->SaveExperimentState();
#
# Save a copy of the files for testbed information gathering (long term).
#
$experiment->SaveLogFiles();
#
......
......@@ -1269,6 +1269,13 @@ if (defined($logname)) {
system("cp -fp $logname $workdir/" . EXPTLOGNAME());
}
#
# Save the final experiment state so that we get a running record of
# the state on disk, for post-mortem debugging. This will get copied
# to the expinfo directory in the next line.
#
$experiment->SaveExperimentState();
#
# Try to copy off the files for testbed information gathering.
#
......
......@@ -942,12 +942,6 @@ sub doSwapout($) {
#
if ( $type >= CLEANUP ) {
print STDERR "Resetting DB.\n";
if (0 && $type == CLEANUP) {
$experiment->ClearBackupState();
$experiment->BackupPhysicalState();
$experiment->SaveBackupState();
$experiment->ClearBackupState();
}
# Add purge flag.
$experiment->RemovePhysicalState(1);
# Special.
......
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