From fff922e9003d95e107c94f6d99820c9cf37fd76a Mon Sep 17 00:00:00 2001
From: David Bigagli <david@schedmd.com>
Date: Mon, 2 Dec 2013 11:05:49 -0800
Subject: [PATCH] Fixed sh5util loop when there are no node-step files.

---
 NEWS                                                   | 1 +
 src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c | 8 ++++++++
 testsuite/expect/test12.6                              | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 1d0fc14c16d..940242ce070 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ documents those changes that are of interest to users and admins.
  -- proctrack/cgroup - Add locking to prevent race condition where one job step
     is ending for a user or job at the same time another job stepsis starting
     and the user or job container is deleted from under the starting job step.
+ -- Fixed sh5util loop when there are no node-step files.
 
 * Changes in Slurm 2.6.4
 ========================
diff --git a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
index 497ce5a642b..838b752d85f 100644
--- a/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
+++ b/src/plugins/acct_gather_profile/hdf5/sh5util/sh5util.c
@@ -1024,6 +1024,14 @@ static int _merge_step_files(void)
 			H5Gclose(jgid_nodes);
 			H5Gclose(jgid_step);
 		}
+
+		/* If we did not find the step 0
+		 * bail out.
+		 */
+		if (stepx == 0
+			&& !found_files)
+			break;
+
 		stepx++;
 	}
 
diff --git a/testsuite/expect/test12.6 b/testsuite/expect/test12.6
index fe6cc0092fd..932525a0e28 100755
--- a/testsuite/expect/test12.6
+++ b/testsuite/expect/test12.6
@@ -162,7 +162,7 @@ expect {
 }
 
 set hdf5_file "job_$job_id.h5"
-set srun_pid [spawn $sh5util -j $job_id -l Node:TimeSeries -s Tasks -o $file_out]
+set srun_pid [spawn $sh5util -j $job_id -E -l Node:TimeSeries -s Tasks -o $file_out]
 expect {
 	timeout {
 		send_user "\nFAILURE: sh5util extract not responding\n"
-- 
GitLab