Commit ba46c3d0 authored by Timothy Stack's avatar Timothy Stack

Change the archive '-d' option to clean the experiment directory

before the next sync instead of immediately after creating the
archive.  Should work better when used with the '$ns report' event,
otherwise stale data gets left around.
parent d0261e85
...@@ -308,7 +308,7 @@ int send_report(simulator_agent_t sa, char *args) ...@@ -308,7 +308,7 @@ int send_report(simulator_agent_t sa, char *args)
file = NULL; file = NULL;
} }
if ((file = popenf("loghole --port=%d --quiet archive", "r", if ((file = popenf("loghole --port=%d --quiet archive --delete", "r",
DEFAULT_RPC_PORT)) == NULL) { DEFAULT_RPC_PORT)) == NULL) {
strcpy(loghole_name, eid); strcpy(loghole_name, eid);
error("failed to archive log holes\n"); error("failed to archive log holes\n");
......
...@@ -238,8 +238,12 @@ example, the input parameters. If the argument to this option is is a single ...@@ -238,8 +238,12 @@ example, the input parameters. If the argument to this option is is a single
dash (\fB-\fR) the comment will be read from standard in. dash (\fB-\fR) the comment will be read from standard in.
.TP .TP
\fB-d\fR, \fB--delete \fB-d\fR, \fB--delete
Delete the files in the log directory after producing the archive. The default After creating the archive, mark the experiment as
action is to leave the files in place until the user is ready to delete them. .I clean-on-sync
so that any stale data is cleaned out before performing the next
.B sync
operation. Currently, the mark is a file named ".cleanonsync" in the
experiment log directory.
.SH CHANGE .SH CHANGE
The The
.B change .B change
......
...@@ -54,6 +54,8 @@ EXTENSIONS = [ ".zip" ] ...@@ -54,6 +54,8 @@ EXTENSIONS = [ ".zip" ]
LINK_DUMP_FMT = [ "trace_%s-%s.xmit", "trace_%s-%s.recv" ] LINK_DUMP_FMT = [ "trace_%s-%s.xmit", "trace_%s-%s.recv" ]
CLEANFILE = ".cleanonsync"
DOT_LOGHOLES = """+ /var/ DOT_LOGHOLES = """+ /var/
+ /var/emulab/ + /var/emulab/
+ /var/emulab/logs/ + /var/emulab/logs/
...@@ -258,8 +260,8 @@ def archive_usage(): ...@@ -258,8 +260,8 @@ def archive_usage():
print " will be displayed in the listing generated" print " will be displayed in the listing generated"
print " by the 'show' action. Use a single dash " print " by the 'show' action. Use a single dash "
print " (-) to read the comment from standard in." print " (-) to read the comment from standard in."
print " -d, --delete Delete the files in the log directory" print " -d, --delete Mark the experiment as clean-on-sync to"
print " after producing the archive." print " remove stale data before another sync."
print print
print "Required arguments:" print "Required arguments:"
print " archive-name The name of the archive to create." print " archive-name The name of the archive to create."
...@@ -765,11 +767,7 @@ def do_archive(args): ...@@ -765,11 +767,7 @@ def do_archive(args):
zf.close() zf.close()
if delete_dir: if delete_dir:
for entry in os.listdir(logdir): open(CLEANFILE, 'w')
if os.path.isdir(entry):
os.rmdir(entry)
pass
pass
pass pass
if VERBOSITY == VERBOSITY_MACHINE: if VERBOSITY == VERBOSITY_MACHINE:
...@@ -931,6 +929,11 @@ def do_sync(args, mode="sync", must_be_active=1): ...@@ -931,6 +929,11 @@ def do_sync(args, mode="sync", must_be_active=1):
logdir = os.path.join(EXPDIR_FMT % { "PID" : PID, "EID" : EID }, "logs") logdir = os.path.join(EXPDIR_FMT % { "PID" : PID, "EID" : EID }, "logs")
os.chdir(logdir) os.chdir(logdir)
if os.path.exists(CLEANFILE):
do_clean(["-f", "-e"])
os.unlink(CLEANFILE)
pass
fp = open(os.path.join(logdir, ".logholes"), "w") fp = open(os.path.join(logdir, ".logholes"), "w")
os.chmod(fp.name, 0664) os.chmod(fp.name, 0664)
fp.write(DOT_LOGHOLES) fp.write(DOT_LOGHOLES)
......
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