save works
This commit is contained in:
parent
47fc32b02c
commit
43dc12a36c
19 changed files with 80 additions and 72 deletions
|
|
@ -8,6 +8,7 @@ endif
|
||||||
|
|
||||||
apiserver_ext_deps = [
|
apiserver_ext_deps = [
|
||||||
libxce_dep,
|
libxce_dep,
|
||||||
|
librtti_dep,
|
||||||
c_capnproto_dep,
|
c_capnproto_dep,
|
||||||
ssl_dep,
|
ssl_dep,
|
||||||
tinylog_dep,
|
tinylog_dep,
|
||||||
|
|
|
||||||
|
|
@ -376,14 +376,6 @@ int cluster_build_resources(cluster_t* c)
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((res->flags & XCE_RESF_GLOBAL) != 0) {
|
|
||||||
res->idx = c->n_shared_res;
|
|
||||||
c->n_shared_res++;
|
|
||||||
} else {
|
|
||||||
res->idx = c->n_host_res;
|
|
||||||
c->n_host_res++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,18 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#if defined(__has_c_attribute) && __has_c_attribute(gnu::constructor)
|
||||||
|
#define CONSTRUCTOR(prio) [[gnu::constructor(prio)]]
|
||||||
|
#define DESTRUCTOR(prio) [[gnu::destructor(prio)]]
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define CONSTRUCTOR(prio) __attribute__((constructor(prio)))
|
||||||
|
#define DESTRUCTOR(prio) __attribute__((destructor(prio)))
|
||||||
|
#else
|
||||||
|
#define CONSTRUCTOR(prio)
|
||||||
|
#define DESTRUCTOR(prio)
|
||||||
|
#warning "No constructor support found"
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef uint64_t jobid_t;
|
typedef uint64_t jobid_t;
|
||||||
|
|
||||||
#define BUG_EMAIL "rshen@shenrs.eu"
|
#define BUG_EMAIL "rshen@shenrs.eu"
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,6 @@ typedef struct {
|
||||||
int myidx;
|
int myidx;
|
||||||
int master;
|
int master;
|
||||||
int ncontrollers;
|
int ncontrollers;
|
||||||
int n_shared_res;
|
|
||||||
int n_host_res;
|
|
||||||
delaymgr_t delaymgr;
|
delaymgr_t delaymgr;
|
||||||
scheduler_t sched;
|
scheduler_t sched;
|
||||||
var jobmgr;
|
var jobmgr;
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@
|
||||||
#include "jobj.h"
|
#include "jobj.h"
|
||||||
#include "kv.h"
|
#include "kv.h"
|
||||||
#include "mylock.h"
|
#include "mylock.h"
|
||||||
|
#include "preason.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xce/types.h"
|
#include "xce/types.h"
|
||||||
#include "xstring.h"
|
#include "xstring.h"
|
||||||
#include "preason.h"
|
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
mylock_t lock;
|
mylock_t lock;
|
||||||
|
|
@ -588,11 +588,11 @@ static void job_destroy(meta_obj_t* obj)
|
||||||
if (j->job.run_usage != NULL) {
|
if (j->job.run_usage != NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < j->job.run_usage->num_hosts; i ++) {
|
for (i = 0; i < j->job.run_usage->num_hosts; i++) {
|
||||||
if (j->job.run_usage->host_runusage[i] != NULL) {
|
if (j->job.run_usage->host_runusage[i] != NULL) {
|
||||||
FREEUP(j->job.run_usage->host_runusage[i]->host_name);
|
FREEUP(j->job.run_usage->host_runusage[i]->host_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
FREEUP(j->job.run_usage->host_runusage[i]);
|
FREEUP(j->job.run_usage->host_runusage[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,13 +126,15 @@ static xce_resource_t* makeResource_(var resmgr, xce_resource_t* r)
|
||||||
resobj = makeInstance(&resobj_type, r);
|
resobj = makeInstance(&resobj_type, r);
|
||||||
if (resobj != NULL) {
|
if (resobj != NULL) {
|
||||||
rc = key_add(resmgr, (void*)resobj->name, (void*)resobj);
|
rc = key_add(resmgr, (void*)resobj->name, (void*)resobj);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
destroy(resobj);
|
destroy(resobj);
|
||||||
|
|
||||||
errno = -rc;
|
errno = -rc;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resobj->idx = rc;
|
||||||
}
|
}
|
||||||
return resobj;
|
return resobj;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,8 @@ int parse_section(xce_resreq_data_t* resreq, char* data, char** errmsg)
|
||||||
*errmsg = NULL;
|
*errmsg = NULL;
|
||||||
ctx.input = data;
|
ctx.input = data;
|
||||||
|
|
||||||
|
memset(resreq, 0x0, sizeof(*resreq));
|
||||||
|
|
||||||
p = xce_section_create(&ctx);
|
p = xce_section_create(&ctx);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
|
||||||
|
|
@ -281,8 +281,6 @@ static void test_job_create(void)
|
||||||
&& (j2->job.submit->mintasks == 1) && (j2->job.submit->maxtasks == 5)
|
&& (j2->job.submit->mintasks == 1) && (j2->job.submit->maxtasks == 5)
|
||||||
&& (j2->job.submit->user_group == NULL));
|
&& (j2->job.submit->user_group == NULL));
|
||||||
|
|
||||||
dereference(j2);
|
|
||||||
|
|
||||||
destroy(jobmgr);
|
destroy(jobmgr);
|
||||||
|
|
||||||
job_obj_fini();
|
job_obj_fini();
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@ static void test_queue_create(void)
|
||||||
|
|
||||||
TEST_ASSERT_TRUE(q != NULL);
|
TEST_ASSERT_TRUE(q != NULL);
|
||||||
|
|
||||||
dereference(q);
|
|
||||||
|
|
||||||
destroy(qmgr);
|
destroy(qmgr);
|
||||||
xstring_table_fini();
|
xstring_table_fini();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ void test_parse_section_fail(void)
|
||||||
"same[type] same[abcd] affinity[core(20)]";
|
"same[type] same[abcd] affinity[core(20)]";
|
||||||
char* errmsg = NULL;
|
char* errmsg = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
xce_resreq_data_t data;
|
xce_resreq_data_t data = {0};
|
||||||
|
|
||||||
rc = parse_section(&data, (char*)resreq, &errmsg);
|
rc = parse_section(&data, (char*)resreq, &errmsg);
|
||||||
TEST_ASSERT_TRUE(rc < 0);
|
TEST_ASSERT_TRUE(rc < 0);
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ static void test_worker_create(void)
|
||||||
&& (w->host.attrs->cpufactor == attrs1.cpufactor)
|
&& (w->host.attrs->cpufactor == attrs1.cpufactor)
|
||||||
&& (w->host.attrs->maxcpus == attrs1.maxcpus));
|
&& (w->host.attrs->maxcpus == attrs1.maxcpus));
|
||||||
|
|
||||||
dereference(w);
|
|
||||||
destroy(workermgr);
|
destroy(workermgr);
|
||||||
|
|
||||||
xstring_table_fini();
|
xstring_table_fini();
|
||||||
|
|
|
||||||
|
|
@ -305,10 +305,10 @@ int match_limit(xce_limit_t* limit, int global, ...)
|
||||||
int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
|
int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
|
||||||
char* project)
|
char* project)
|
||||||
{
|
{
|
||||||
char resname[2 * XCE_MAXNAME_LEN + 1];
|
size_t bufsize = 0;
|
||||||
xce_consumer_t* c = NULL;
|
FILE* fp = NULL;
|
||||||
char* p = NULL;
|
xce_consumer_t* c = NULL;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
*vname = NULL;
|
*vname = NULL;
|
||||||
if ((vname == NULL) || (limit == NULL) || (user == NULL) || (queue == NULL)
|
if ((vname == NULL) || (limit == NULL) || (user == NULL) || (queue == NULL)
|
||||||
|
|
@ -316,50 +316,33 @@ int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(resname, 0x0, sizeof(resname));
|
fp = open_memstream(vname, &bufsize);
|
||||||
|
if (fp == NULL) {
|
||||||
p = &resname[0];
|
return -errno;
|
||||||
|
|
||||||
rc = sprintf(p, "limit=%s", limit->name);
|
|
||||||
if (rc < 0) {
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p += rc;
|
fprintf(fp, "limit=%s", limit->name);
|
||||||
|
|
||||||
c = limit->consumers[CONSUMER_USER];
|
c = limit->consumers[CONSUMER_USER];
|
||||||
|
|
||||||
if ((c != NULL) && (c->per_consumer == 1)) {
|
if ((c != NULL) && (c->per_consumer == 1)) {
|
||||||
rc = sprintf(p, "/u=%s", user);
|
fprintf(fp, "/u=%s", user);
|
||||||
if (rc < 0) {
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = limit->consumers[CONSUMER_QUEUE];
|
c = limit->consumers[CONSUMER_QUEUE];
|
||||||
if ((c != NULL) && (c->per_consumer == 1)) {
|
if ((c != NULL) && (c->per_consumer == 1)) {
|
||||||
rc = sprintf(p, "/q=%s", queue);
|
fprintf(fp, "/q=%s", queue);
|
||||||
if (rc < 0) {
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c = limit->consumers[CONSUMER_PROJECT];
|
c = limit->consumers[CONSUMER_PROJECT];
|
||||||
if ((c != NULL) && (c->per_consumer == 1)) {
|
if ((c != NULL) && (c->per_consumer == 1)) {
|
||||||
rc = sprintf(p, "/p=%s", project);
|
fprintf(fp, "/p=%s", project);
|
||||||
if (rc < 0) {
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
p += rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*vname = strdup(resname);
|
fflush(fp);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
if ((*vname) != NULL) {
|
if ((*vname) != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,10 @@ static int xzarray_ensure_items(xzarray_t* array, int mincap)
|
||||||
/* this will make we can get next free
|
/* this will make we can get next free
|
||||||
* location quickly
|
* location quickly
|
||||||
*/
|
*/
|
||||||
array->pos = array->caps;
|
if (array->data[array->pos].inuse) {
|
||||||
|
array->pos = array->caps;
|
||||||
|
}
|
||||||
|
|
||||||
array->caps = nc;
|
array->caps = nc;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,18 @@ if get_option('buildtype') == 'debug'
|
||||||
# add -DWITH_DEBUG=1
|
# add -DWITH_DEBUG=1
|
||||||
add_project_arguments(['-DWITH_DEBUG=1',
|
add_project_arguments(['-DWITH_DEBUG=1',
|
||||||
'-DDEBUG',
|
'-DDEBUG',
|
||||||
|
'-O0',
|
||||||
|
'-fno-lto',
|
||||||
'-Wno-cpp',
|
'-Wno-cpp',
|
||||||
'-fno-inline',
|
'-fno-inline',
|
||||||
'-fno-omit-frame-pointer',
|
'-fno-omit-frame-pointer',
|
||||||
'-ggdb',
|
'-ggdb',
|
||||||
|
'-gdwarf-4',
|
||||||
'-g3',
|
'-g3',
|
||||||
'-fvar-tracking',
|
'-fvar-tracking',
|
||||||
'-fvar-tracking-assignments',
|
'-fvar-tracking-assignments',
|
||||||
], language: ['c', 'cpp'])
|
], language: ['c', 'cpp'])
|
||||||
|
add_project_link_arguments('-fno-lto', language: ['c', 'cpp'])
|
||||||
with_debug=true
|
with_debug=true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,13 @@ stdenv.mkDerivation {
|
||||||
separateDebugInfo = true;
|
separateDebugInfo = true;
|
||||||
}))
|
}))
|
||||||
packcc
|
packcc
|
||||||
] ++ (if withDebug then [librtti_debug] else [librtti]);
|
] ++ (if withDebug then [
|
||||||
|
(librtti_debug.overrideAttrs (oldattrs: {
|
||||||
|
separateDebugInfo = true;
|
||||||
|
}))
|
||||||
|
] else [
|
||||||
|
librtti
|
||||||
|
]);
|
||||||
|
|
||||||
build-system = [ pkgs.meson ];
|
build-system = [ pkgs.meson ];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xcelimit.h"
|
#include "xcelimit.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
#include "xstring.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
var limits;
|
var limits;
|
||||||
|
|
@ -398,7 +399,7 @@ static int build_limit_vres_requests(xce_scheduler_t* sched,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rq->res = strdup(vres->vres->name);
|
rq->res = makeString(vres->vres->name);
|
||||||
rq->value = get_vres_value(ctx, vres);
|
rq->value = get_vres_value(ctx, vres);
|
||||||
|
|
||||||
xlist_store(requests, rq);
|
xlist_store(requests, rq);
|
||||||
|
|
|
||||||
|
|
@ -342,8 +342,8 @@ static int sched_update_res_accounts(xce_scheduler_t* sched, zarray_t* array,
|
||||||
|
|
||||||
for (i = 0; i < naccounts; i++) {
|
for (i = 0; i < naccounts; i++) {
|
||||||
float val = accounts[i]->used + accounts[i]->reserved;
|
float val = accounts[i]->used + accounts[i]->reserved;
|
||||||
TRACE("%s resource %d old %f delta %f charge %d", __func__, vals[i],
|
TRACE("%s resource %d old %f delta %f charge %d", __func__, idxs[i],
|
||||||
val, charge);
|
vals[i], val, charge);
|
||||||
if (charge) {
|
if (charge) {
|
||||||
vals[i] += val;
|
vals[i] += val;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
#include "xcealloc.h"
|
#include "xcealloc.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
#include "xvec.h"
|
#include "xvec.h"
|
||||||
|
#include "xstring.h"
|
||||||
|
|
||||||
void kill_sched_job(void* arg)
|
void kill_sched_job(void* arg)
|
||||||
{
|
{
|
||||||
|
|
@ -29,7 +30,7 @@ request_res_t* make_resource_request(char* res, float value)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->res = strdup(res);
|
req->res = makeString(res);
|
||||||
req->value = value;
|
req->value = value;
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
|
|
@ -111,9 +112,9 @@ static int make_sched_obj(xce_sched_obj_t* obj, xce_scheduler_t* sched,
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
obj->user = strdup(j->submit->user);
|
obj->user = makeString(j->submit->user);
|
||||||
obj->queue = strdup(j->submit->queue);
|
obj->queue = makeString(j->submit->queue);
|
||||||
obj->project = strdup(j->submit->project_name);
|
obj->project = makeString(j->submit->project_name);
|
||||||
|
|
||||||
xlist_init(&(obj->glimits), 8);
|
xlist_init(&(obj->glimits), 8);
|
||||||
zarray_init(&(obj->hlimits), 32, NULL);
|
zarray_init(&(obj->hlimits), 32, NULL);
|
||||||
|
|
@ -218,7 +219,7 @@ xce_sched_queue_t* make_sched_queue(void* arg, xce_queue_t* q)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->name = strdup(q->queue);
|
queue->name = makeString(q->queue);
|
||||||
queue->attrs = q->attrs;
|
queue->attrs = q->attrs;
|
||||||
queue->status = q->status;
|
queue->status = q->status;
|
||||||
queue->priority = q->priority;
|
queue->priority = q->priority;
|
||||||
|
|
@ -259,7 +260,7 @@ xce_sched_worker_t* make_sched_worker(void* arg, xce_worker_t* w)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
worker->name = strdup(w->name);
|
worker->name = makeString(w->name);
|
||||||
worker->status = w->status;
|
worker->status = w->status;
|
||||||
worker->idx = -1;
|
worker->idx = -1;
|
||||||
|
|
||||||
|
|
@ -288,7 +289,7 @@ void kill_sched_user(void* arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREEUP(user->name);
|
dereference(user->name);
|
||||||
FREEUP(user);
|
FREEUP(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,7 +303,7 @@ xce_sched_user_t* make_sched_user(void* arg, char* name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
user->name = strdup(name);
|
user->name = makeString(name);
|
||||||
|
|
||||||
sched_add_user(sched, user);
|
sched_add_user(sched, user);
|
||||||
|
|
||||||
|
|
@ -317,7 +318,7 @@ void kill_sched_project(void* arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREEUP(project->name);
|
dereference(project->name);
|
||||||
FREEUP(project);
|
FREEUP(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,9 +333,9 @@ xce_sched_project_t* make_sched_project(void* arg, char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((name == NULL) || (strlen(name) == 0)) {
|
if ((name == NULL) || (strlen(name) == 0)) {
|
||||||
project->name = strdup("default");
|
project->name = makeString("default");
|
||||||
} else {
|
} else {
|
||||||
project->name = strdup(name);
|
project->name = makeString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_add_project(sched, project);
|
sched_add_project(sched, project);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "preason.h"
|
#include "preason.h"
|
||||||
|
#include "resobj.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "xcealloc.h"
|
#include "xcealloc.h"
|
||||||
|
|
@ -465,11 +466,18 @@ static int sched_init_resources(xce_scheduler_t* sched)
|
||||||
xce_conf4sched_t* config = sched->config;
|
xce_conf4sched_t* config = sched->config;
|
||||||
|
|
||||||
for (i = 0; i < config->n_resources; i++) {
|
for (i = 0; i < config->n_resources; i++) {
|
||||||
xce_resource_t* r = config->resources[i];
|
xce_resource_t* r = config->resources[i];
|
||||||
|
xce_resource_t* r1 = NULL;
|
||||||
|
|
||||||
lock(sched->resmgr, RTTI_LOCK_WRITE);
|
if (r == NULL) {
|
||||||
key_add(sched->resmgr, (void*)r->name, (void*)r);
|
continue;
|
||||||
unlock(sched->resmgr);
|
}
|
||||||
|
|
||||||
|
r1 = makeResource(sched->resmgr, r);
|
||||||
|
|
||||||
|
if (r1 == NULL) {
|
||||||
|
ERROR("%s add resource %s failed", __func__, r->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue