diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c index c3a8a8ea720070ca035663743e3b15a7abc1888f..1d923fc6e5f8ef082ccbac0783452cf1626f276c 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.c @@ -1327,20 +1327,59 @@ extern int remove_cluster_tables(mysql_conn_t *mysql_conn, char *cluster_name) extern int setup_association_limits(slurmdb_association_rec_t *assoc, char **cols, char **vals, char **extra, qos_level_t qos_level, - bool get_fs) + bool for_add) { if (!assoc) return SLURM_ERROR; - if ((int32_t)assoc->shares_raw >= 0) { - xstrcat(*cols, ", shares"); - xstrfmtcat(*vals, ", %u", assoc->shares_raw); - xstrfmtcat(*extra, ", shares=%u", assoc->shares_raw); - } else if ((assoc->shares_raw == INFINITE) || get_fs) { + if (for_add) { + /* If we are adding we should make sure we don't get + old reside sitting around from a former life. + */ + if (assoc->shares_raw == NO_VAL) + assoc->shares_raw = INFINITE; + if (assoc->grp_cpu_mins == (uint64_t)NO_VAL) + assoc->grp_cpu_mins = (uint64_t)INFINITE; + if (assoc->grp_cpu_run_mins == (uint64_t)NO_VAL) + assoc->grp_cpu_run_mins = (uint64_t)INFINITE; + if (assoc->grp_cpus == NO_VAL) + assoc->grp_cpus = INFINITE; + if (assoc->grp_jobs == NO_VAL) + assoc->grp_jobs = INFINITE; + if (assoc->grp_nodes == NO_VAL) + assoc->grp_nodes = INFINITE; + if (assoc->grp_submit_jobs == NO_VAL) + assoc->grp_submit_jobs = INFINITE; + if (assoc->grp_wall == NO_VAL) + assoc->grp_wall = INFINITE; + if (assoc->max_cpu_mins_pj == (uint64_t)NO_VAL) + assoc->max_cpu_mins_pj = (uint64_t)INFINITE; + if (assoc->max_cpu_run_mins == (uint64_t)NO_VAL) + assoc->max_cpu_run_mins = (uint64_t)INFINITE; + if (assoc->max_cpus_pj == NO_VAL) + assoc->max_cpus_pj = INFINITE; + if (assoc->max_jobs == NO_VAL) + assoc->max_jobs = INFINITE; + if (assoc->max_nodes_pj == NO_VAL) + assoc->max_nodes_pj = INFINITE; + if (assoc->max_submit_jobs == NO_VAL) + assoc->max_submit_jobs = INFINITE; + if (assoc->max_wall_pj == NO_VAL) + assoc->max_wall_pj = INFINITE; + if (assoc->def_qos_id == NO_VAL) + assoc->def_qos_id = INFINITE; + } + + if (assoc->shares_raw == INFINITE) { xstrcat(*cols, ", shares"); xstrcat(*vals, ", 1"); xstrcat(*extra, ", shares=1"); assoc->shares_raw = 1; + } else if ((assoc->shares_raw != NO_VAL) + && (int32_t)assoc->shares_raw >= 0) { + xstrcat(*cols, ", shares"); + xstrfmtcat(*vals, ", %u", assoc->shares_raw); + xstrfmtcat(*extra, ", shares=%u", assoc->shares_raw); } if (assoc->grp_cpu_mins == (uint64_t)INFINITE) { @@ -1356,6 +1395,19 @@ extern int setup_association_limits(slurmdb_association_rec_t *assoc, assoc->grp_cpu_mins); } + if (assoc->grp_cpu_run_mins == (uint64_t)INFINITE) { + xstrcat(*cols, ", grp_cpu_run_mins"); + xstrcat(*vals, ", NULL"); + xstrcat(*extra, ", grp_cpu_run_mins=NULL"); + } else if ((assoc->grp_cpu_run_mins != (uint64_t)NO_VAL) + && ((int64_t)assoc->grp_cpu_run_mins >= 0)) { + xstrcat(*cols, ", grp_cpu_run_mins"); + xstrfmtcat(*vals, ", %"PRIu64"", + assoc->grp_cpu_run_mins); + xstrfmtcat(*extra, ", grp_cpu_run_mins=%"PRIu64"", + assoc->grp_cpu_run_mins); + } + if (assoc->grp_cpus == INFINITE) { xstrcat(*cols, ", grp_cpus"); xstrcat(*vals, ", NULL"); @@ -1435,6 +1487,19 @@ extern int setup_association_limits(slurmdb_association_rec_t *assoc, assoc->max_cpu_mins_pj); } + if (assoc->max_cpu_run_mins == (uint64_t)INFINITE) { + xstrcat(*cols, ", max_cpu_run_mins"); + xstrcat(*vals, ", NULL"); + xstrcat(*extra, ", max_cpu_run_mins=NULL"); + } else if ((assoc->max_cpu_run_mins != (uint64_t)NO_VAL) + && ((int64_t)assoc->max_cpu_run_mins >= 0)) { + xstrcat(*cols, ", max_cpu_run_mins"); + xstrfmtcat(*vals, ", %"PRIu64"", + assoc->max_cpu_run_mins); + xstrfmtcat(*extra, ", max_cpu_run_mins=%"PRIu64"", + assoc->max_cpu_run_mins); + } + if (assoc->max_cpus_pj == INFINITE) { xstrcat(*cols, ", max_cpus_pj"); xstrcat(*vals, ", NULL"); diff --git a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h index 7fa0340a590e015cfb55911d6975395b22604c9e..962211080d5d28729694ba4d69c13921eb0697fb 100644 --- a/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h +++ b/src/plugins/accounting_storage/mysql/accounting_storage_mysql.h @@ -118,7 +118,7 @@ extern int remove_cluster_tables(mysql_conn_t *mysql_conn, char *cluster_name); extern int setup_association_limits(slurmdb_association_rec_t *assoc, char **cols, char **vals, char **extra, qos_level_t qos_level, - bool get_fs); + bool for_add); extern int modify_common(mysql_conn_t *mysql_conn, uint16_t type, time_t now, diff --git a/src/plugins/accounting_storage/mysql/as_mysql_qos.c b/src/plugins/accounting_storage/mysql/as_mysql_qos.c index 5db0f655225266a6470e11370a77df8a15206401..2434d2916f6670b816f0d6ed2223906e2ee2d0dd 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_qos.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_qos.c @@ -78,11 +78,56 @@ static int _preemption_loop(mysql_conn_t *mysql_conn, int begin_qosid, static int _setup_qos_limits(slurmdb_qos_rec_t *qos, char **cols, char **vals, - char **extra, char **added_preempt) + char **extra, char **added_preempt, + bool for_add) { if (!qos) return SLURM_ERROR; + if (for_add) { + /* If we are adding we should make sure we don't get + old reside sitting around from a former life. + */ + if (!qos->description) + qos->description = xstrdup(""); + if (qos->flags & QOS_FLAG_NOTSET) + qos->flags = 0; + if (qos->grp_cpu_mins == (uint64_t)NO_VAL) + qos->grp_cpu_mins = (uint64_t)INFINITE; + if (qos->grp_cpu_run_mins == (uint64_t)NO_VAL) + qos->grp_cpu_run_mins = (uint64_t)INFINITE; + if (qos->grp_cpus == NO_VAL) + qos->grp_cpus = INFINITE; + if (qos->grp_jobs == NO_VAL) + qos->grp_jobs = INFINITE; + if (qos->grp_nodes == NO_VAL) + qos->grp_nodes = INFINITE; + if (qos->grp_submit_jobs == NO_VAL) + qos->grp_submit_jobs = INFINITE; + if (qos->grp_wall == NO_VAL) + qos->grp_wall = INFINITE; + if (qos->max_cpu_mins_pj == (uint64_t)NO_VAL) + qos->max_cpu_mins_pj = (uint64_t)INFINITE; + if (qos->grp_cpu_run_mins == (uint64_t)NO_VAL) + qos->grp_cpu_run_mins = (uint64_t)INFINITE; + if (qos->max_cpus_pj == NO_VAL) + qos->max_cpus_pj = INFINITE; + if (qos->max_jobs_pu == NO_VAL) + qos->max_jobs_pu = INFINITE; + if (qos->max_nodes_pj == NO_VAL) + qos->max_nodes_pj = INFINITE; + if (qos->max_submit_jobs_pu == NO_VAL) + qos->max_submit_jobs_pu = INFINITE; + if (qos->max_wall_pj == NO_VAL) + qos->max_wall_pj = INFINITE; + if (qos->preempt_mode == (uint16_t)NO_VAL) + qos->preempt_mode = (uint16_t)INFINITE; + if (qos->usage_factor == (double)NO_VAL) + qos->usage_factor = (double)INFINITE; + if (qos->usage_thres == (double)NO_VAL) + qos->usage_thres = (double)INFINITE; + } + if (qos->description) { xstrcat(*cols, ", description"); xstrfmtcat(*vals, ", '%s'", qos->description); @@ -321,7 +366,7 @@ static int _setup_qos_limits(slurmdb_qos_rec_t *qos, xfree(preempt_val); } - if ((qos->usage_factor != (int16_t)NO_VAL) + if ((qos->preempt_mode != (uint16_t)NO_VAL) && ((int16_t)qos->preempt_mode >= 0)) { qos->preempt_mode &= (~PREEMPT_MODE_GANG); xstrcat(*cols, ", preempt_mode"); @@ -396,7 +441,8 @@ extern int as_mysql_add_qos(mysql_conn_t *mysql_conn, uint32_t uid, now, now, object->name); xstrfmtcat(extra, ", mod_time=%ld", now); - _setup_qos_limits(object, &cols, &vals, &extra, &added_preempt); + _setup_qos_limits(object, &cols, &vals, + &extra, &added_preempt, 1); if (added_preempt) { object->preempt_bitstr = bit_alloc(g_qos_count); bit_unfmt(object->preempt_bitstr, added_preempt+1); @@ -545,7 +591,8 @@ extern List as_mysql_modify_qos(mysql_conn_t *mysql_conn, uint32_t uid, xstrcat(extra, ")"); } - _setup_qos_limits(qos, &tmp_char1, &tmp_char2, &vals, &added_preempt); + _setup_qos_limits(qos, &tmp_char1, &tmp_char2, + &vals, &added_preempt, 0); if (added_preempt) { preempt_bitstr = bit_alloc(g_qos_count); bit_unfmt(preempt_bitstr, added_preempt+1);