Skip to content

Commit

Permalink
mxqd: Only start jobs we are qualified for
Browse files Browse the repository at this point in the history
Check, whether this server is qualified to start jobs from a group.
Lazy-evaluate qualification criteria and cache the result.
Don't start jobs we are not qualified for.

For now, the only qualification criteria is, that our short or fully
qualified hostname is not included the the excluded_servers set of the
group.

This can later be expanded to additional criteria (e.g. hostconfig or
processor flags).
  • Loading branch information
donald committed Apr 13, 2020
1 parent ef0161d commit 51b6443
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "mxq.h"

#include "mxqd_control.h"
#include "keywordset.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 @@ -546,6 +547,16 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
}

server->hostname = arg_hostname;
{
char *dot=index(arg_hostname,'.');
if (dot) {
server->hostname_short = mx_malloc_forever(dot-arg_hostname+1);
strncpy(server->hostname_short, arg_hostname, dot-arg_hostname);
server->hostname_short[dot-arg_hostname] = 0;
} else
server->hostname_short = mx_strdup_forever(arg_hostname);
}

server->daemon_name = arg_daemon_name;
server->initial_path = arg_initial_path;
server->initial_tmpdir = arg_initial_tmpdir;
Expand Down Expand Up @@ -1277,6 +1288,26 @@ unsigned long start_job(struct mxq_group_list *glist)

/**********************************************************************/

static int server_is_qualified(struct mxq_server *server, struct mxq_group *group) {
int is_qualified = 1;
if (*group->group_disabled_servers != 0) {
struct keywordset *kws = keywordset_new(group->group_disabled_servers);
if ( keywordset_ismember(kws, server->hostname_short)
|| keywordset_ismember(kws, server->hostname) )
is_qualified = 0;
keywordset_free(kws);
}
return (is_qualified);
}

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 @@ -1319,6 +1350,8 @@ 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 Expand Up @@ -1472,6 +1505,7 @@ void server_free(struct mxq_server *server)
mx_free_null(server->finished_jobsdir);
mx_flock_free(server->flock);
mx_free_null(server->supgid);
mx_free_null(server->hostname_short);

mx_log_finish();
}
Expand Down
4 changes: 4 additions & 0 deletions mxqd.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct mxq_group_list {
unsigned long global_threads_running;
unsigned long global_slots_running;

int server_is_qualified_evaluated;
int server_is_qualified;

short orphaned;
};

Expand Down Expand Up @@ -95,6 +98,7 @@ struct mxq_server {
unsigned long long int starttime;
char *host_id;
char *hostname;
char *hostname_short;
char *daemon_name;
char *pidfilename;
char *finished_jobsdir;
Expand Down
3 changes: 3 additions & 0 deletions mxqd_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ static void _group_list_init(struct mxq_group_list *glist)
glist->slots_max = slots_max;
glist->memory_max = memory_max;

glist->server_is_qualified_evaluated = 0;
glist->server_is_qualified = 0;

glist->orphaned = 0;
}

Expand Down

0 comments on commit 51b6443

Please sign in to comment.