support limit

This commit is contained in:
Rongsong Shen 2026-01-12 15:20:51 +08:00
parent bef32ace38
commit ecf1916d78
33 changed files with 3036 additions and 243 deletions

View file

@ -8,6 +8,7 @@
#include "worker.h"
#include "xce/cluster_def.h"
#include "xce/types.h"
#include "xcelimit.h"
extern void collect_shared_resvals(cluster_t*, collect_check_fn_t, int*,
xce_val_with_idx_t***);
@ -52,8 +53,44 @@ static int xcesched_push_workerlist(cluster_t* c, xlist_t* l)
static int xcesched_push_configs(cluster_t* c)
{
xce_configdata_t configdata;
int rc = 0;
xce_configdata_t configdata;
int rc = 0;
xce_limit_config_t limit1_config = {
.name = "limit1",
.per_user = 0,
.per_queue = 0,
.per_project = 0,
.per_host = 0,
.users
= &(xce_group_config_t) { .members
= { .count = 1, .data = (char*[]) { "all" } },
.ex_members
= { .count = 1,
.data = (char*[]) { "rshen" } } },
.queues = NULL,
.projects = NULL,
.hosts = NULL,
.val
= &(xce_limit_val_t) { .resname = "slots", .percent = 0, .val = 3.0 }
};
xce_limit_config_t limit2_config = {
.name = "limits2",
.per_user = 1,
.per_queue = 1,
.per_project = 1,
.per_host = 1,
.users = &(xce_group_config_t) { .members
= { .count = 1,
.data = (char*[]) { "rshen" } } },
.queues
= &(xce_group_config_t) { .members = { .count = 1,
.data = (char*[]) { "xce" } } },
.projects = NULL,
.hosts = NULL,
.val = &(xce_limit_val_t) { .resname = "mem", .percent = 1, .val = 0.2 }
};
xce_limit_config_t* limits[] = { &limit1_config, &limit2_config };
int nlimits = 2;
memset(&configdata, 0x0, sizeof(configdata));
@ -76,6 +113,17 @@ static int xcesched_push_configs(cluster_t* c)
configdata.data.conf4sched->ugroups = c->myconf->cluster_config->ugroups;
configdata.data.conf4sched->n_hgroups = c->myconf->cluster_config->nhgroups;
configdata.data.conf4sched->hgroups = c->myconf->cluster_config->hgroups;
#if 0 /* FIXME: we use builtin limit currently */
configdata.data.conf4sched->nlimits = c->myconf->cluster_config->nlimits;
configdata.data.conf4sched->limits = c->myconf->cluster_config->limits;
#else
configdata.data.conf4sched->nlimits = nlimits;
configdata.data.conf4sched->limits = &(limits[0]);
#endif
configdata.data.conf4sched->nhproviders
= c->myconf->cluster_config->nhproviders;
configdata.data.conf4sched->hproviders
= c->myconf->cluster_config->hproviders;
/* add resources */
configdata.data_which = ConfigData_data_schedconfig;