Skip to content

Commit

Permalink
Move server_is_qualified() to mxqd_control
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Apr 19, 2020
1 parent f5e009c commit e6ef2ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------

Expand Down Expand Up @@ -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)
Expand Down
47 changes: 0 additions & 47 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
36 changes: 35 additions & 1 deletion mxqd_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e6ef2ad

Please sign in to comment.