diff --git a/src/api/cache_info.c b/src/api/cache_info.c index 7b75cfa9fb3a139aa6c9c58ceac747fa68bb0961..84be31a752de13a8ae6d283a1a5307907e0fad49 100644 --- a/src/api/cache_info.c +++ b/src/api/cache_info.c @@ -1,11 +1,11 @@ /*****************************************************************************\ - * cache_info.c - get/print the job state information of slurm + * cache_info.c - get the current slurmctld cache information ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. * Copyright (C) 2008-2010 Lawrence Livermore National Security. - * Copyright (C) 2013 SchedMD - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Stephen Trofinoff <stephen.trofinoff@cscs.ch> + * Copyright (C) 2014 CSCS + * Produced at CSCS + * Written by Stephen Trofinoff * CODE-OCEC-09-009. All rights reserved. * * This file is part of SLURM, a resource management program. @@ -42,27 +42,14 @@ # include "config.h" #endif -#include <ctype.h> -#include <errno.h> -#include <grp.h> -#include <pwd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <time.h> #include "slurm/slurm.h" #include "slurm/slurm_errno.h" -#include "src/common/forward.h" -#include "src/common/node_select.h" -#include "src/common/parse_time.h" -#include "src/common/slurm_auth.h" #include "src/common/slurm_protocol_api.h" -#include "src/common/uid.h" -#include "src/common/xstring.h" /* slurm_load_cache() * @@ -70,9 +57,7 @@ * */ extern int -slurm_load_cache(time_t t, - cache_info_msg_t **cache_info, - uint16_t show_flags) +slurm_load_cache(cache_info_msg_t **cache_info, uint16_t show_flags) { int cc; slurm_msg_t msg_request; @@ -84,7 +69,6 @@ slurm_load_cache(time_t t, slurm_msg_t_init(&msg_reply); msg_request.msg_type = REQUEST_CACHE_INFO; - req.last_update = t; req.show_flags = show_flags; msg_request.data = &req; @@ -97,7 +81,7 @@ slurm_load_cache(time_t t, *cache_info = msg_reply.data; break; case RESPONSE_SLURM_RC: - cc = ((return_code_msg_t*)msg_reply.data)->return_code; + cc = ((return_code_msg_t *)msg_reply.data)->return_code; slurm_free_return_code_msg(msg_reply.data); if (cc) /* slurm_seterrno_ret() is a macro ... sigh */ slurm_seterrno(cc); @@ -105,7 +89,7 @@ slurm_load_cache(time_t t, return -1; default: slurm_seterrno_ret(SLURM_UNEXPECTED_MSG_ERROR); - break; + break; } return SLURM_PROTOCOL_SUCCESS; diff --git a/src/scontrol/info_cache.c b/src/scontrol/info_cache.c index f2dc4fc20f96b5ed6b0bbeb9f4bf4a803f5b5cc2..07bc86a261ad6950398d67ed39145c242feff25b 100644 --- a/src/scontrol/info_cache.c +++ b/src/scontrol/info_cache.c @@ -1,11 +1,11 @@ /*****************************************************************************\ - * info_lics.c - licenses information functions for scontrol. + * info_cache.c - Cache information functions for scontrol. ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. * Copyright (C) 2008-2010 Lawrence Livermore National Security. * Copyright (C) 2013 SchedMD - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Stephen Trofinoff <stephen.trofinoff@cscs.ch> + * Produced at CSCS. + * Written by Stephen Trofinoff * CODE-OCEC-09-009. All rights reserved. * * This file is part of SLURM, a resource management program. @@ -55,12 +55,11 @@ scontrol_print_cache(const char *name) int cc; cache_info_msg_t *msg; uint16_t show_flags; - static time_t last_update; show_flags = 0; /* call the controller to get the meat */ - cc = slurm_load_cache(last_update, &msg, show_flags); + cc = slurm_load_cache( &msg, show_flags); if (cc != SLURM_PROTOCOL_SUCCESS) { /* Hosed, crap out. */ @@ -70,7 +69,6 @@ scontrol_print_cache(const char *name) return; } - last_update = time(NULL); /* print the info */ _print_cache_info(name, msg); @@ -78,65 +76,69 @@ scontrol_print_cache(const char *name) /* free at last */ slurm_free_cache_info_msg(msg); + + return; } -static void -_print_cache_info(const char *name, cache_info_msg_t *msg) +static void _print_cache_info(const char *name, cache_info_msg_t *msg) { char time_str[32], tmp_str[128]; int cc; - slurm_make_time_str((time_t *)&msg->last_update, - time_str, sizeof(time_str)); + slurm_make_time_str((time_t *)&msg->time_stamp, + time_str, sizeof(time_str)); snprintf(tmp_str, sizeof(tmp_str), "Controller cache data as of %s\n", - time_str); + time_str); printf("%s\n", tmp_str); - if (!msg->num_users) + + if (!msg->num_users) { printf("No users currently cached in Slurm.\n"); + } else { - for (cc = 0; msg->num_users && cc < msg->num_users; cc++) { - if (name && strcmp(msg->cache_user_array[cc].name, name)) - continue; - printf("UserName=%s%sUID=%u DefAccount=%s OldName=%s " - "DefWckey=%s\n", - msg->cache_user_array[cc].name, - one_liner ? " " : "\n ", - msg->cache_user_array[cc].uid, - msg->cache_user_array[cc].default_acct, - msg->cache_user_array[cc].old_name, - msg->cache_user_array[cc].default_wckey); - if (name) - break; + for (cc = 0; cc < msg->num_users; cc++) { + if (name && strcmp(msg->cache_user_array[cc].name, name)) + continue; + printf("UserName=%s%sUID=%u DefAccount=%s OldName=%s " + "DefWckey=%s\n", + msg->cache_user_array[cc].name, + one_liner ? " " : "\n ", + msg->cache_user_array[cc].uid, + msg->cache_user_array[cc].default_acct, + msg->cache_user_array[cc].old_name, + msg->cache_user_array[cc].default_wckey); + if (name) + break; + } } - if (!msg->num_assocs) + if (!msg->num_assocs) { printf("No associations currently cached in Slurm.\n"); + } else { - - /* Do NOT prematurely break from loop if printing records from - * a specified user as there could be more than one associaton - * record per user. - */ - for (cc = 0; msg->num_assocs && cc < msg->num_assocs; cc++) { - if (name) { - if (!msg->cache_assoc_array[cc].user - || strcmp(msg->cache_assoc_array[cc].user, - name)) - continue; - } - printf("ClusterName=%s Account=%s ParentAccount=%s " - "UserName=%s UID=%u Partition=%s%s Share=%u " - "GrpJobs=%u GrpNodes=%u GrpCPUs=%u GrpMem=%u " - "GrpSubmit=%u GrpWall=%u GrpCPUMins=%"PRIu64" " - "MaxJobs=%u MaxNodes=%u MaxCPUs=%u MaxSubmit=%u " - "MaxWall=%u MaxCPUMins=%"PRIu64" QOS=%u " - "GrpCPURunMins=%"PRIu64" MaxCPURunMins=%"PRIu64" ID=%u " - "DefAssoc=%u Lft=%u ParentID=%u Rgt=%u\n", - msg->cache_assoc_array[cc].cluster, - msg->cache_assoc_array[cc].acct, - msg->cache_assoc_array[cc].parent_acct, - msg->cache_assoc_array[cc].user, + /* Do NOT prematurely break from loop if printing records from + * a specified user as there could be more than one associaton + * record per user. + */ + for (cc = 0; cc < msg->num_assocs; cc++) { + if (name) { + if ( !msg->cache_assoc_array[cc].user || + strcmp(msg->cache_assoc_array[cc].user, name)) + continue; + } + printf("ClusterName=%s Account=%s ParentAccount=%s " + "UserName=%s UID=%u Partition=%s%s Share=%u " + "GrpJobs=%u GrpNodes=%u GrpCPUs=%u GrpMem=%u " + "GrpSubmit=%u GrpWall=%u GrpCPUMins=%"PRIu64" " + "MaxJobs=%u MaxNodes=%u MaxCPUs=%u MaxSubmit=%u " + "MaxWall=%u MaxCPUMins=%"PRIu64" QOS=%u " + "GrpCPURunMins=%"PRIu64" " + "MaxCPURunMins=%"PRIu64" ID=%u " + "DefAssoc=%u Lft=%u ParentID=%u Rgt=%u\n", + msg->cache_assoc_array[cc].cluster, + msg->cache_assoc_array[cc].acct, + msg->cache_assoc_array[cc].parent_acct, + msg->cache_assoc_array[cc].user, msg->cache_assoc_array[cc].uid, msg->cache_assoc_array[cc].partition, one_liner ? " " : "\n " , @@ -158,9 +160,10 @@ _print_cache_info(const char *name, cache_info_msg_t *msg) msg->cache_assoc_array[cc].grp_cpu_run_mins, msg->cache_assoc_array[cc].max_cpu_run_mins, msg->cache_assoc_array[cc].id, - msg->cache_assoc_array[cc].is_def, - msg->cache_assoc_array[cc].lft, - msg->cache_assoc_array[cc].parent_id, - msg->cache_assoc_array[cc].rgt); + msg->cache_assoc_array[cc].is_def, + msg->cache_assoc_array[cc].lft, + msg->cache_assoc_array[cc].parent_id, + msg->cache_assoc_array[cc].rgt); + } } } diff --git a/src/slurmctld/caches.c b/src/slurmctld/caches.c index c916b5828b4bc40f288949e76aa72d1e9ea3719f..5a7ca66b18b7f797bee37aa9bb043aaec0240148 100644 --- a/src/slurmctld/caches.c +++ b/src/slurmctld/caches.c @@ -1,9 +1,9 @@ /*****************************************************************************\ - * caches.c - Functions for handling cluster-wide consumable resources + * caches.c - Functions for obtaining slurmctld cache information ***************************************************************************** * Copyright (C) 2008-2011 Lawrence Livermore National Security. - * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). - * Written by Stephen Trofinoff <stephen.trofinoff@cscs.ch> + * Produced at CSCS + * Written by Stephen Trofinoff * CODE-OCEC-09-009. All rights reserved. * * This file is part of SLURM, a resource management program. @@ -36,9 +36,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \*****************************************************************************/ -#include <ctype.h> -#include <errno.h> -#include <pthread.h> #include <stdlib.h> #include <string.h> @@ -50,23 +47,21 @@ #include "src/common/macros.h" #include "src/common/xmalloc.h" #include "src/common/xstring.h" -/*#include "src/slurmctld/reservation.h"*/ #include "src/slurmctld/slurmctld.h" -/*#include "src/common/slurm_accounting_storage.h"*/ static pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER; -static void _pack_cache(slurmdb_user_rec_t *cache, Buf buffer, - uint16_t protocol_version); -static void _pack_assoc(slurmdb_assoc_rec_t *assoc, Buf buffer, - uint16_t protocol_version); +static void _pack_cache(slurmdb_user_rec_t *cache, Buf buffer, + uint16_t protocol_version); +static void _pack_assoc(slurmdb_association_rec_t *assoc, Buf buffer, + uint16_t protocol_version); /* * * Return controller cache information to the library. */ -void +extern void get_all_cache_info(char **buffer_ptr, int *buffer_size, - uid_t uid, uint16_t protocol_version) + uid_t uid, uint16_t protocol_version) { ListIterator iter; slurmdb_user_rec_t * cache_entry; @@ -74,7 +69,7 @@ get_all_cache_info(char **buffer_ptr, int *buffer_size, int tmp_offset; Buf buffer; time_t now = time(NULL); - slurmdb_assoc_rec_t* assoc_entry; + slurmdb_association_rec_t* assoc_entry; uint32_t assocs_packed; debug2("%s: calling for all cache user records", __func__); @@ -104,8 +99,8 @@ get_all_cache_info(char **buffer_ptr, int *buffer_size, list_iterator_destroy(iter); } - if ( assoc_mgr_assoc_list ) { - iter = list_iterator_create(assoc_mgr_assoc_list); + if ( assoc_mgr_association_list ) { + iter = list_iterator_create(assoc_mgr_association_list); while ((assoc_entry = list_next(iter))) { _pack_assoc(assoc_entry, buffer, protocol_version); ++assocs_packed; @@ -146,13 +141,13 @@ get_all_cache_info(char **buffer_ptr, int *buffer_size, static void _pack_cache(slurmdb_user_rec_t *cache, Buf buffer, uint16_t protocol_version) { - if (protocol_version >= SLURM_15_08_PROTOCOL_VERSION) { - pack16 (cache->admin_level, buffer); - packstr(cache->default_acct, buffer); + if (protocol_version >= SLURM_14_03_PROTOCOL_VERSION) { + pack16 (cache->admin_level, buffer); + packstr(cache->default_acct, buffer); packstr(cache->default_wckey, buffer); - packstr(cache->name, buffer); - packstr(cache->old_name, buffer); - pack32 (cache->uid, buffer); + packstr(cache->name, buffer); + packstr(cache->old_name, buffer); + pack32 (cache->uid, buffer); } else { error("\ %s: protocol_version %hu not supported", __func__, protocol_version); @@ -160,38 +155,38 @@ _pack_cache(slurmdb_user_rec_t *cache, Buf buffer, uint16_t protocol_version) } static void -_pack_assoc(slurmdb_assoc_rec_t *assoc, Buf buffer, - uint16_t protocol_version) +_pack_assoc(slurmdb_association_rec_t *assoc, Buf buffer, + uint16_t protocol_version) { - if (protocol_version >= SLURM_15_08_PROTOCOL_VERSION) { - packstr(assoc->acct, buffer); - packstr(assoc->cluster, buffer); - pack32 (assoc->def_qos_id, buffer); - pack64 (assoc->grp_cpu_mins, buffer); + if (protocol_version >= SLURM_14_03_PROTOCOL_VERSION) { + packstr(assoc->acct, buffer); + packstr(assoc->cluster, buffer); + pack32 (assoc->def_qos_id, buffer); + pack64 (assoc->grp_cpu_mins, buffer); pack64 (assoc->grp_cpu_run_mins, buffer); - pack32 (assoc->grp_cpus, buffer); - pack32 (assoc->grp_jobs, buffer); - pack32 (assoc->grp_mem, buffer); - pack32 (assoc->grp_nodes, buffer); - pack32 (assoc->grp_submit_jobs, buffer); - pack32 (assoc->grp_wall, buffer); - pack32 (assoc->id, buffer); - pack16 (assoc->is_def, buffer); - pack32 (assoc->lft, buffer); - pack64 (assoc->max_cpu_mins_pj, buffer); + pack32 (assoc->grp_cpus, buffer); + pack32 (assoc->grp_jobs, buffer); + pack32 (assoc->grp_mem, buffer); + pack32 (assoc->grp_nodes, buffer); + pack32 (assoc->grp_submit_jobs, buffer); + pack32 (assoc->grp_wall, buffer); + pack32 (assoc->id, buffer); + pack16 (assoc->is_def, buffer); + pack32 (assoc->lft, buffer); + pack64 (assoc->max_cpu_mins_pj, buffer); pack64 (assoc->max_cpu_run_mins, buffer); - pack32 (assoc->max_cpus_pj, buffer); - pack32 (assoc->max_jobs, buffer); - pack32 (assoc->max_nodes_pj, buffer); - pack32 (assoc->max_submit_jobs, buffer); - pack32 (assoc->max_wall_pj, buffer); - packstr(assoc->parent_acct, buffer); - pack32 (assoc->parent_id, buffer); - packstr(assoc->partition, buffer); - pack32 (assoc->rgt, buffer); - pack32 (assoc->shares_raw, buffer); - pack32 (assoc->uid, buffer); - packstr(assoc->user, buffer); + pack32 (assoc->max_cpus_pj, buffer); + pack32 (assoc->max_jobs, buffer); + pack32 (assoc->max_nodes_pj, buffer); + pack32 (assoc->max_submit_jobs, buffer); + pack32 (assoc->max_wall_pj, buffer); + packstr(assoc->parent_acct, buffer); + pack32 (assoc->parent_id, buffer); + packstr(assoc->partition, buffer); + pack32 (assoc->rgt, buffer); + pack32 (assoc->shares_raw, buffer); + pack32 (assoc->uid, buffer); + packstr(assoc->user, buffer); } else { error("\ %s: protocol_version %hu not supported", __func__, protocol_version);