merge job rusage and pending reason support

This commit is contained in:
Rongsong Shen 2025-12-16 14:36:28 +08:00
parent 30824ae5ea
commit cb0c7fe9e7
82 changed files with 4280 additions and 2561 deletions

View file

@ -21,7 +21,8 @@ int my_snprintf(char* buf, size_t size, const char* fmt, ...)
return ret;
}
if ((size_t)ret >= size) {
WARN("my_snprintf: output truncated for format: %s (needed %d bytes, buffer size %zu)",
WARN("my_snprintf: output truncated for format: %s (needed %d bytes, "
"buffer size %zu)",
fmt, ret + 1, size);
}
return ret;
@ -33,14 +34,16 @@ int my_snprintf(char* buf, size_t size, const char* fmt, ...)
* like "/tmp/as_in_XXXXXX.json". The 'X's will be replaced with a unique
* sequence to ensure the file name is unique.
*
* Returns 0 on success, -1 on failure. file_name will contain the name of the created file.
* Returns 0 on success, -1 on failure. file_name will contain the name of the
* created file.
*/
int create_temp_file(char* file_name)
{
// Call mkstemp to create a temporary file
int fd = mkstemp(file_name);
if (fd == -1) {
ERROR("Failed to create temporary file, errno %d : %s.", errno, strerror(errno));
ERROR("Failed to create temporary file, errno %d : %s.", errno,
strerror(errno));
return -1;
}
close(fd);
@ -87,10 +90,8 @@ void print_demand_list(scaler_demand_array_t* d_list)
INFO("Number of demands: %d", d_list->num);
for (int i = 0; i < d_list->num; i++) {
scaler_demand_t* demand = &d_list->data[i];
INFO("Demand %d: provider=%s, template=%s, count=%d",
i,
demand->tpl_id.provider_name,
demand->tpl_id.template_id,
INFO("Demand %d: provider=%s, template=%s, count=%d", i,
demand->tpl_id.provider_name, demand->tpl_id.template_id,
demand->count);
}
}
@ -112,9 +113,9 @@ void print_request(void* data)
return;
}
INFO("Request: req_id=%s, type=%d, status=%d, provider=%s, template=%s, count=%d",
request->request_id ? request->request_id : "NULL",
request->type,
INFO("Request: req_id=%s, type=%d, status=%d, provider=%s, template=%s, "
"count=%d",
request->request_id ? request->request_id : "NULL", request->type,
request->status,
request->tpl_id.provider_name ? request->tpl_id.provider_name : "NULL",
request->tpl_id.template_id ? request->tpl_id.template_id : "NULL",
@ -153,10 +154,8 @@ void print_instance(void* p)
inst->instance_id ? inst->instance_id : "NULL",
inst->hostname ? inst->hostname : "NULL",
inst->private_ip ? inst->private_ip : "NULL",
inst->public_ip ? inst->public_ip : "NULL",
(long)inst->launch_time,
inst->alloc_status,
inst->inst_state ? inst->inst_state : "NULL",
inst->public_ip ? inst->public_ip : "NULL", (long)inst->launch_time,
inst->alloc_status, inst->inst_state ? inst->inst_state : "NULL",
inst->tpl_id.provider_name ? inst->tpl_id.provider_name : "NULL",
inst->tpl_id.template_id ? inst->tpl_id.template_id : "NULL",
inst->request_id ? inst->request_id : "NULL",
@ -193,7 +192,4 @@ int float_cmp_ex(float a, float b, float ep)
return 1;
}
int float_cmp(float a, float b)
{
return float_cmp_ex(a, b, DEFAULT_EPSILON);
}
int float_cmp(float a, float b) { return float_cmp_ex(a, b, DEFAULT_EPSILON); }