-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flux-shutdown: add --gc garbage collection option #4303
Changes from all commits
4bea672
27153d0
d2cbcb8
d5df488
c6d50a0
1adb5fd
d7c2043
358f21b
9c4b56c
e9cfaa7
9f6da91
fb2ad9c
ddec542
2ae2799
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# See tmpfiles.d(5) | ||
# remove Flux dump files older than 30 days | ||
|
||
e /var/lib/flux/dump - - - 30d |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,6 @@ | |
# Allow connector-local more time to start listening on socket | ||
RANK=$(FLUX_LOCAL_CONNECTOR_RETRY_COUNT=30 flux getattr rank) | ||
|
||
if ! content_backing=$(flux getattr content.backing-module 2>/dev/null); then | ||
content_backing=content-sqlite | ||
fi | ||
|
||
# Usage: modload {all|<rank>} modname [args ...] | ||
modload() { | ||
local where=$1; shift | ||
|
@@ -16,7 +12,34 @@ modload() { | |
} | ||
|
||
modload all barrier | ||
modload 0 ${content_backing} | ||
|
||
if test $RANK -eq 0; then | ||
backingmod=$(flux getattr content.backing-module 2>/dev/null) || : | ||
backingmod=${backingmod:-content-sqlite} | ||
dumpfile=$(flux getattr content.restore 2>/dev/null) || : | ||
if test -n "${dumpfile}"; then | ||
if test "${dumpfile}" = "auto"; then | ||
statedir=$(flux getattr statedir 2>/dev/null) || : | ||
dumplink="${statedir:-.}/dump/RESTORE" | ||
if test -h "${dumplink}"; then | ||
dumpfile=$(readlink -f ${dumplink}) || : | ||
else | ||
dumpfile="" | ||
dumplink="" | ||
fi | ||
fi | ||
fi | ||
if test -n "${dumpfile}"; then | ||
flux module load ${backingmod} truncate | ||
echo "restoring content from ${dumpfile}" | ||
flux restore --quiet --checkpoint ${dumpfile} | ||
if test -n "${dumplink}"; then | ||
rm -f ${dumplink} | ||
fi | ||
Comment on lines
+36
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should only remove the link if the restore is successful? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but the rc1 shebang is |
||
else | ||
flux module load ${backingmod} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use modload for consistency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ibid |
||
fi | ||
fi | ||
|
||
modload all kvs | ||
modload all kvs-watch | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,25 @@ modrm all kvs | |
|
||
flux content flush || exit_rc=1 | ||
|
||
backingmod=$(flux getattr content.backing-module 2>/dev/null) | ||
modrm 0 ${backingmod:-content-sqlite} | ||
if test $RANK -eq 0; then | ||
backingmod=$(flux getattr content.backing-module 2>/dev/null) | ||
backingmod=${backingmod:-content-sqlite} | ||
dumpfile=$(flux getattr content.dump 2>/dev/null) | ||
if test $exit_rc -eq 0 -a -n "${dumpfile}"; then | ||
if test "${dumpfile}" = "auto"; then | ||
statedir=$(flux getattr statedir 2>/dev/null) | ||
mkdir -p "${statedir:-.}/dump" | ||
dumpfile="${statedir:-.}/dump/$(date +%Y%m%d_%H%M%S).tgz" | ||
dumplink="${statedir:-.}/dump/RESTORE" | ||
fi | ||
echo "dumping content to ${dumpfile}" | ||
if flux dump --quiet --checkpoint ${dumpfile}; then | ||
test -n "$dumplink" && ln -s $(basename ${dumpfile}) ${dumplink} | ||
else | ||
exit_rc=1 | ||
fi | ||
fi | ||
flux module remove ${backingmod} || exit_rc=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh that makes sense, you have the |
||
fi | ||
|
||
exit $exit_rc |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ struct content_sqlite { | |
struct content_stats stats; | ||
const char *journal_mode; | ||
const char *synchronous; | ||
bool truncate; | ||
}; | ||
|
||
static void log_sqlite_error (struct content_sqlite *ctx, const char *fmt, ...) | ||
|
@@ -600,12 +601,15 @@ void stats_get_cb (flux_t *h, | |
|
||
/* Open the database file ctx->dbfile and set up the database. | ||
*/ | ||
static int content_sqlite_opendb (struct content_sqlite *ctx) | ||
static int content_sqlite_opendb (struct content_sqlite *ctx, bool truncate) | ||
{ | ||
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; | ||
char s[128]; | ||
int count; | ||
|
||
if (truncate) | ||
(void)unlink (ctx->dbfile); | ||
|
||
if (sqlite3_open_v2 (ctx->dbfile, &ctx->db, flags, NULL) != SQLITE_OK) { | ||
log_sqlite_error (ctx, "opening %s", ctx->dbfile); | ||
goto error; | ||
|
@@ -786,7 +790,10 @@ static struct content_sqlite *content_sqlite_create (flux_t *h) | |
return NULL; | ||
} | ||
|
||
static int process_args (struct content_sqlite *ctx, int argc, char **argv) | ||
static int process_args (struct content_sqlite *ctx, | ||
int argc, | ||
char **argv, | ||
bool *truncate) | ||
{ | ||
int i; | ||
for (i = 0; i < argc; i++) { | ||
|
@@ -796,8 +803,11 @@ static int process_args (struct content_sqlite *ctx, int argc, char **argv) | |
else if (strncmp ("synchronous=", argv[i], 12) == 0) { | ||
ctx->synchronous = argv[i] + 12; | ||
} | ||
else if (strcmp ("truncate", argv[i]) == 0) { | ||
*truncate = true; | ||
} | ||
else { | ||
flux_log_error (ctx->h, "Unknown module option: '%s'", argv[i]); | ||
flux_log (ctx->h, LOG_ERR, "Unknown module option: '%s'", argv[i]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps should stylize do a similar change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh and I guess w/ |
||
return -1; | ||
} | ||
} | ||
|
@@ -807,15 +817,17 @@ static int process_args (struct content_sqlite *ctx, int argc, char **argv) | |
int mod_main (flux_t *h, int argc, char **argv) | ||
{ | ||
struct content_sqlite *ctx; | ||
bool truncate = false; | ||
int rc = -1; | ||
|
||
if (!(ctx = content_sqlite_create (h))) { | ||
flux_log_error (h, "content_sqlite_create failed"); | ||
return -1; | ||
} | ||
if (process_args (ctx, argc, argv) < 0) // override pragmas set above | ||
// override pragmas set above | ||
if (process_args (ctx, argc, argv, &truncate) < 0) | ||
goto done; | ||
if (content_sqlite_opendb (ctx) < 0) | ||
if (content_sqlite_opendb (ctx, truncate) < 0) | ||
goto done; | ||
if (content_register_backing_store (h, "content-sqlite") < 0) | ||
goto done; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use modload for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same deal here