From e6ef2ad4d965c56d1c0d566de5b0667d3c9e4fa6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 19 Apr 2020 17:47:56 +0200 Subject: [PATCH] Move server_is_qualified() to mxqd_control We need to make a difference between jobs, the server is not able to run currently (because it doesn't have enough free slots) and jobs, which it is not able to run at all (e.g. because the server is on the groups blacklist). Only in the first case does thes server need to get into the WAITING state and stop takeing jobs from groups of users with already used more than their fair share of the cluster. Evaluate group contraints when the group is loaded and set glist->jobs_max to 0 if we can't run jobs from a group. --- Makefile | 2 +- mxqd.c | 47 ----------------------------------------------- mxqd_control.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index e400bdaa..20b5d268 100644 --- a/Makefile +++ b/Makefile @@ -337,6 +337,7 @@ mxqd_control.h += mxqd_control.h mxqd_control.h += mxq_group.h mxqd_control.h += mxq_job.h mxqd_control.h += mxqd.h +mxqd_control.h += parser.tab.h ### mx_getopt.h -------------------------------------------------------- @@ -488,7 +489,6 @@ mxqd.o: $(mxq_group.h) mxqd.o: $(mxq_job.h) mxqd.o: $(mx_mysql.h) mxqd.o: $(keywordset.h) -mxqd.o: parser.tab.h mxqd.o: CFLAGS += $(CFLAGS_MYSQL) mxqd.o: CFLAGS += $(CFLAGS_MXQ_INITIAL_PATH) mxqd.o: CFLAGS += $(CFLAGS_MXQ_INITIAL_TMPDIR) diff --git a/mxqd.c b/mxqd.c index 7b35d8d2..7274b9e1 100644 --- a/mxqd.c +++ b/mxqd.c @@ -44,7 +44,6 @@ #include "mxqd_control.h" #include "keywordset.h" -#include "parser.tab.h" #ifndef MXQ_INITIAL_PATH # define MXQ_INITIAL_PATH "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" @@ -1402,50 +1401,6 @@ unsigned long start_job(struct mxq_group_list *glist) return 1; } -/**********************************************************************/ - -static int server_is_qualified(struct mxq_server *server, struct mxq_group *group) { - - /* server in exclusive mode and no whitelist on group ? */ - if ( server->daemon.daemon_flags && *group->group_whitelist == 0 ) - return 0; - - if (*group->group_whitelist != 0) { - _mx_cleanup_(keywordset_free_byref) struct keywordset *kws = keywordset_new(group->group_whitelist); - if (! (keywordset_ismember(kws, server->hostname_short) || keywordset_ismember(kws, server->hostname))) - return 0; - } - - if (*group->group_blacklist != 0) { - _mx_cleanup_(keywordset_free_byref) struct keywordset *kws = keywordset_new(group->group_whitelist); - if (keywordset_ismember(kws, server->hostname_short) || keywordset_ismember(kws, server->hostname)) - return 0; - } - - if (*group->prerequisites != 0) { - struct parser_context parser_context = { - .input = group->prerequisites, - .tags = server->prerequisites, - .pos=0, - .result = 0, - }; - if (yyparse(&parser_context)) - return 0; // syntax error in expression - if (parser_context.result == 0) - return 0; // avaluated to false - } - - return (1); -} - -static int server_is_qualified_cached(struct mxq_server *server, struct mxq_group_list *glist) { - if (!glist->server_is_qualified_evaluated) { - glist->server_is_qualified = server_is_qualified(server, &glist->group); - glist->server_is_qualified_evaluated = 1; - } - return glist->server_is_qualified; -} - unsigned long start_user(struct mxq_user_list *ulist, long slots_to_start) { struct mxq_server *server; @@ -1488,8 +1443,6 @@ unsigned long start_user(struct mxq_user_list *ulist, long slots_to_start) if (df_scratch/1024/1024/1024 < group->job_tmpdir_size + 20) { continue; } - if (!server_is_qualified_cached(server, glist)) - continue; mx_log_info(" group=%s(%d):%lu slots_to_start=%ld slots_per_job=%lu :: trying to start job for group.", group->user_name, group->user_uid, group->group_id, slots_to_start, glist->slots_per_job); diff --git a/mxqd_control.c b/mxqd_control.c index bbbd8549..b90fa3fd 100644 --- a/mxqd_control.c +++ b/mxqd_control.c @@ -6,9 +6,40 @@ #include "mxq_job.h" #include "mxq_group.h" - +#include "keywordset.h" +#include "parser.tab.h" #include "mxqd.h" +static int server_is_qualified(struct mxq_server *server, struct mxq_group *group) { + + /* server in exclusive mode and no whitelist on group ? */ + if ( server->daemon.daemon_flags && *group->group_whitelist == 0 ) + return 0; + if (*group->group_whitelist != 0) { + _mx_cleanup_(keywordset_free_byref) struct keywordset *kws = keywordset_new(group->group_whitelist); + if (! (keywordset_ismember(kws, server->hostname_short) || keywordset_ismember(kws, server->hostname))) + return 0; + } + if (*group->group_blacklist != 0) { + _mx_cleanup_(keywordset_free_byref) struct keywordset *kws = keywordset_new(group->group_whitelist); + if (keywordset_ismember(kws, server->hostname_short) || keywordset_ismember(kws, server->hostname)) + return 0; + } + if (*group->prerequisites != 0) { + struct parser_context parser_context = { + .input = group->prerequisites, + .tags = server->prerequisites, + .pos=0, + .result = 0, + }; + if (yyparse(&parser_context)) + return 0; // syntax error in expression + if (parser_context.result == 0) + return 0; // evaluated to false + } + return (1); +} + static void _group_list_init(struct mxq_group_list *glist) { struct mxq_server *server; @@ -73,6 +104,9 @@ static void _group_list_init(struct mxq_group_list *glist) if (server->maxtime && group->job_time > server->maxtime) jobs_max=0; + if (!server_is_qualified(server, group)) + jobs_max=0; + slots_max = jobs_max * slots_per_job; memory_max = jobs_max * group->job_memory;