sinfo does not check for differing reason timestamps when coalescing output
for sinfo -R and -Rl. This leads to incorrect timestamps in output if two
nodes are down with the same reason string but at a different time.
This fix adds a timestamp_reason_flag and a test to determine if
timestamps are equivalent before coalescing lines of output.
(Note: This patch is not an ideal fix for this issue. It would be much
better if the sinfo output handlers (_print_* in sinfo/print.c) could
also be called by sinfo to see if two lines of output were going
to be equivalent and could be coalesced. This would do away with the
separately kept "match_flags" which (as is seen here) are cumbersome
to maintain.)
---
src/sinfo/opts.c | 3 +++
src/sinfo/sinfo.c | 5 +++++
src/sinfo/sinfo.h | 1 +
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/sinfo/opts.c b/src/sinfo/opts.c
index a2fdf82..b1fc5f2 100644
--- a/src/sinfo/opts.c
+++ b/src/sinfo/opts.c
@@ -565,6 +565,7 @@ _parse_format( char* format )
right_justify,
suffix );
} else if (field[0] == 'H') {
+ params.match_flags.reason_timestamp_flag = true;
format_add_timestamp( params.format_list,
field_size,
right_justify,
@@ -811,6 +812,8 @@ void _print_options( void )
"true" : "false");
printf("reason_flag = %s\n", params.match_flags.reason_flag ?
"true" : "false");
+ printf("reason_timestamp_flag = %s\n",
+ params.match_flags.reason_timestamp_flag ? "true" :
"false");
printf("root_flag = %s\n", params.match_flags.root_flag ?
"true" : "false");
printf("share_flag = %s\n", params.match_flags.share_flag ?
diff --git a/src/sinfo/sinfo.c b/src/sinfo/sinfo.c
index df687fc..c054e26 100644
--- a/src/sinfo/sinfo.c
+++ b/src/sinfo/sinfo.c
@@ -514,6 +514,11 @@ static bool _match_node_data(sinfo_data_t *sinfo_ptr,
node_info_t *node_ptr)
(_strcmp(node_ptr->reason, sinfo_ptr->reason)))
return false;
+ if (sinfo_ptr->nodes &&
+ params.match_flags.reason_timestamp_flag &&
+ (node_ptr->reason_time != sinfo_ptr->reason_time))
+ return false;
+
if (params.match_flags.state_flag) {
char *state1, *state2;
state1 = node_state_string(node_ptr->node_state);
diff --git a/src/sinfo/sinfo.h b/src/sinfo/sinfo.h
index 8e9dcef..e0cdb2c 100644
--- a/src/sinfo/sinfo.h
+++ b/src/sinfo/sinfo.h
@@ -141,6 +141,7 @@ struct sinfo_match_flags {
bool share_flag;
bool state_flag;
bool weight_flag;
+ bool reason_timestamp_flag;
};
/* Input parameters */
--
1.7.1