From 25c7c04adaa61b1b191e24ff57e152f35665f5f5 Mon Sep 17 00:00:00 2001 From: Brian Christiansen <brian@schedmd.com> Date: Fri, 2 Sep 2016 14:57:10 -0600 Subject: [PATCH] Do commit check after adding federations Was modeled after cluster adding where commit the check was being done before sending the changes to the dbd. But since the dbd isn't making any additional tables for federations -- like it does for clusters -- it can send to the dbd first and make sure they worked and then ask to commit the changes. --- src/sacctmgr/federation_functions.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/sacctmgr/federation_functions.c b/src/sacctmgr/federation_functions.c index e458dbe5363..40c2ad3a280 100644 --- a/src/sacctmgr/federation_functions.c +++ b/src/sacctmgr/federation_functions.c @@ -474,27 +474,23 @@ extern int sacctmgr_add_federation(int argc, char *argv[]) goto end_it; } - /* Since we are creating tables with add federation that can't be - rolled back. So we ask before hand if they are serious - about it so we can rollback if needed. - */ - if (commit_check("Would you like to commit changes?")) { - notice_thread_init(); - rc = acct_storage_g_add_federations(db_conn, my_uid, - federation_list); - notice_thread_fini(); - if (rc == SLURM_SUCCESS) { + notice_thread_init(); + rc = acct_storage_g_add_federations(db_conn, my_uid, + federation_list); + notice_thread_fini(); + + if (rc == SLURM_SUCCESS) { + if (commit_check("Would you like to commit changes?")) { acct_storage_g_commit(db_conn, 1); } else { - fprintf(stderr, " Problem adding federation(s): %s\n", - slurm_strerror(rc)); - /* this isn't really needed, but just to be safe */ + printf(" Changes Discarded\n"); acct_storage_g_commit(db_conn, 0); } } else { - printf(" Changes Discarded\n"); - /* this isn't really needed, but just to be safe */ - acct_storage_g_commit(db_conn, 0); + exit_code = 1; + fprintf(stderr, " Problem adding federation(s): %s\n", + slurm_strerror(rc)); + rc = SLURM_ERROR; } end_it: -- GitLab