From f6dde6872a80b00c6c1b1a78710cb33f0d2debf6 Mon Sep 17 00:00:00 2001 From: rread Date: Mon, 23 Sep 2002 21:27:35 +0000 Subject: [PATCH] * add ignore_error cmd to lctl * use it in lconf during cleanup so errors are non-fatal * return lctl exit status in lconf properly --- lustre/utils/lconf | 21 +++++++++++++++------ lustre/utils/lctl.c | 11 +++++++++++ lustre/utils/parser.c | 21 ++++++++++++++++++--- lustre/utils/parser.h | 1 + 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/lustre/utils/lconf b/lustre/utils/lconf index 4054b4e..467cc0f 100755 --- a/lustre/utils/lconf +++ b/lustre/utils/lconf @@ -227,7 +227,7 @@ class LCTLInterface: self.lctl = 'lctl' else: raise CommandError('lctl', "unable to find lctl binary.") - + def run(self, cmds): """ run lctl @@ -245,9 +245,13 @@ class LCTLInterface: out = p.fromchild.readlines() err = p.childerr.readlines() ret = p.wait() - if ret or len(err): - raise CommandError(self.lctl, err, ret) - return ret, out + if os.WIFEXITED(ret): + rc = os.WEXITSTATUS(ret) + else: + rc = 0 + if rc or len(err): + raise CommandError(self.lctl, err, rc) + return rc, out def network(self, net, nid): @@ -299,6 +303,7 @@ class LCTLInterface: # add a route to a range def del_route(self, net, gw, lo, hi): cmds = """ + ignore_errors network %s del_route %s quit """ % (net, lo) @@ -316,6 +321,7 @@ class LCTLInterface: # add a route to a range def del_route_host(self, net, uuid, gw, tgt): cmds = """ + ignore_errors network %s del_uuid %s del_route %s @@ -325,6 +331,7 @@ class LCTLInterface: # disconnect one connection def disconnect(self, net, nid, port, servuuid): cmds = """ + ignore_errors network %s disconnect %s del_uuid %s @@ -334,6 +341,7 @@ class LCTLInterface: # disconnect all def disconnectAll(self, net): cmds = """ + ignore_errors network %s del_uuid self disconnect @@ -352,6 +360,7 @@ class LCTLInterface: # cleanup a device def cleanup(self, name, uuid): cmds = """ + ignore_errors device $%s cleanup detach @@ -367,7 +376,7 @@ class LCTLInterface: quit""" % (mdsuuid, uuid, stripe_cnt, stripe_sz, stripe_off, pattern, devlist) self.run(cmds) - # cleanup a device + # dump the log file def dump(self, dump_file): cmds = """ debug_kernel %s 1 @@ -1588,4 +1597,4 @@ if __name__ == "__main__": if first_cleanup_error: sys.exit(first_cleanup_error) -2 + diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 1eaf62c..cc41440 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -39,6 +39,11 @@ static int jt_noop(int argc, char **argv) { return 0; } +static int jt_opt_ignore_errors(int argc, char **argv) { + Parser_ignore_errors(1); + return 0; +} + command_t cmdlist[] = { /* Metacommands */ {"--device", jt_opt_device, 0, @@ -47,6 +52,12 @@ command_t cmdlist[] = { {"--threads", jt_opt_threads, 0, "run separate instances of on device \n" "--threads "}, + {"--ignore_errors", jt_opt_ignore_errors, 0, + "ignore errors that occur during script processing\n" + "--ignore_errors"}, + {"ignore_errors", jt_opt_ignore_errors, 0, + "ignore errors that occur during script processing\n" + "ignore_errors"}, /* Network configuration commands */ {"==== network config ====", jt_noop, 0, "network config"}, diff --git a/lustre/utils/parser.c b/lustre/utils/parser.c index 9b75d60..ee77e28 100644 --- a/lustre/utils/parser.c +++ b/lustre/utils/parser.c @@ -44,6 +44,10 @@ static command_t * top_level; /* Top level of commands, initialized by * InitParser */ static char * parser_prompt = NULL;/* Parser prompt, set by InitParser */ static int done; /* Set to 1 if user types exit or quit */ +static int ignore_errors; /* Normally, the parser will quit when + an error occurs in non-interacive + mode. Setting this to non-zero will + force it to keep buggering on. */ /* static functions */ @@ -104,6 +108,11 @@ static command_t *Parser_findargcmd(char *name, command_t cmds[]) return NULL; } +void Parser_ignore_errors(int ignore) +{ + ignore_errors = ignore; +} + int Parser_execarg(int argc, char **argv, command_t cmds[]) { command_t *cmd; @@ -323,7 +332,7 @@ char * readline(char * prompt) int Parser_commands(void) { char *line, *s; - int rc = 0; + int rc = 0, save_error = 0; int interactive; interactive = init_input(); @@ -340,11 +349,17 @@ int Parser_commands(void) rc = execute_line(s); } /* stop on error if not-interactive */ - if (rc != 0 && !interactive) - done = 1; + if (rc != 0 && !interactive) { + if (save_error == 0) + save_error = rc; + if (!ignore_errors) + done = 1; + } free(line); } + if (save_error) + rc = save_error; return rc; } diff --git a/lustre/utils/parser.h b/lustre/utils/parser.h index dead9f5..5aece60 100644 --- a/lustre/utils/parser.h +++ b/lustre/utils/parser.h @@ -34,6 +34,7 @@ void Parser_init(char *, command_t *); /* Set prompt and load command list */ int Parser_commands(void); /* Start the command parser */ void Parser_qhelp(int, char **); /* Quick help routine */ int Parser_help(int, char **); /* Detailed help routine */ +void Parser_ignore_errors(int ignore); /* Set the ignore errors flag */ void Parser_printhelp(char *); /* Detailed help routine */ void Parser_exit(int, char **); /* Shuts down command parser */ int Parser_execarg(int argc, char **argv, command_t cmds[]); -- 1.8.3.1