From 760f6a6d96f40a13061f80a52cc2d67228b56775 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 10 Mar 2008 19:26:19 +0000
Subject: [PATCH] more fixes for accounting filetxt thru slurmdbd

---
 .../filetxt/accounting_storage_filetxt.c      | 15 ++-------------
 .../filetxt/filetxt_jobacct_process.c         | 19 ++++++++++++++++++-
 .../filetxt/filetxt_jobacct_process.h         |  1 +
 src/slurmdbd/proc_req.c                       |  1 +
 4 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
index 15ef72551dc..5e23c1d41de 100644
--- a/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
+++ b/src/plugins/accounting_storage/filetxt/accounting_storage_filetxt.c
@@ -180,21 +180,10 @@ extern int init ( void )
 	struct stat	statbuf;
 	
 	if(first) {
-		char *temp = slurm_get_jobacct_gather_type();
-		char *temp2 = slurm_get_accounting_storage_type();
-		if(!strcasecmp(temp, JOB_ACCT_GATHER_TYPE_NONE)) {
-			fatal("WARNING: You are trying to store job "
-			      "accounting info (%s) without collecting it. "
-			      "This will not work.  If you want to collect "
-			      "accounting data set the jobacct-gather option "
-			      "to something other than '%s'", temp2, temp);
-		}
-		xfree(temp);
-		xfree(temp2);
-
 		debug2("jobacct_init() called");
 		log_file = slurm_get_accounting_storage_loc();
-		
+		if(!log_file)
+			log_file = xstrdup(DEFAULT_STORAGE_LOC);
 		slurm_mutex_lock( &logfile_lock );
 		if (LOGFILE)
 			fclose(LOGFILE);
diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
index fc8e8e44f08..af014776d7a 100644
--- a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
+++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
@@ -45,7 +45,9 @@
 
 #include "src/common/xstring.h"
 #include "src/common/xmalloc.h"
+#include "src/common/slurm_protocol_api.h"
 #include "src/common/jobacct_common.h"
+#include "src/slurmdbd/read_config.h"
 /* Map field names to positions */
 
 /* slurmd uses "(uint32_t) -2" to track data for batch allocations
@@ -1015,13 +1017,17 @@ extern List filetxt_jobacct_process_get_jobs(List selected_steps,
 	int show_full = 0;
 	List ret_job_list = list_create(destroy_jobacct_job_rec);
 	List job_list = list_create(_destroy_filetxt_job_rec);
+
+	if(slurmdbd_conf) {
+		params->opt_filein = slurm_get_accounting_storage_loc();
+	}
+
 	fd = _open_log_file(params->opt_filein);
 	
 	while (fgets(line, BUFFER_SIZE, fd)) {
 		lc++;
 		fptr = line;	/* break the record into NULL-
 				   terminated strings */
-				
 		for (i = 0; i < MAX_RECORD_FIELDS; i++) {
 			f[i] = fptr;
 			fptr = strstr(fptr, " ");
@@ -1141,6 +1147,9 @@ extern List filetxt_jobacct_process_get_jobs(List selected_steps,
 	list_iterator_destroy(itr);
 	list_destroy(job_list);
 
+	if(slurmdbd_conf) {
+		xfree(params->opt_filein);
+	}
 	return ret_job_list;
 }
 
@@ -1175,6 +1184,11 @@ extern void filetxt_jobacct_process_archive(List selected_parts,
 
 	/* Figure out our expiration date */
 	time_t		expiry;
+
+	if(slurmdbd_conf) {
+		params->opt_filein = slurm_get_accounting_storage_loc();
+	}
+
 	expiry = time(NULL)-params->opt_expire;
 	if (params->opt_verbose)
 		fprintf(stderr, "Purging jobs completed prior to %d\n",
@@ -1424,6 +1438,9 @@ finished2:
 			      old_logfile_name);
 	}
 finished:
+	if(slurmdbd_conf) {
+		xfree(params->opt_filein);
+	}
 	fclose(fd);
 	list_destroy(exp_list);
 	list_destroy(keep_list);
diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h
index 071652e6e5e..a5ba22deff7 100644
--- a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h
+++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.h
@@ -44,6 +44,7 @@
 #define _HAVE_FILETXT_JOBACCT_PROCESS_H
 
 #include "src/common/jobacct_common.h"
+#include "src/slurmdbd/read_config.h"
 
 extern List filetxt_jobacct_process_get_jobs(List selected_steps,
 					     List selected_parts,
diff --git a/src/slurmdbd/proc_req.c b/src/slurmdbd/proc_req.c
index 5b8c70579f5..90bce1a28d9 100644
--- a/src/slurmdbd/proc_req.c
+++ b/src/slurmdbd/proc_req.c
@@ -199,6 +199,7 @@ static int _get_jobs(void *db_conn,
 	info("DBD_GET_JOBS: called");
 	memset(&sacct_params, 0, sizeof(sacct_params));
 	sacct_params.opt_cluster = get_jobs_msg->cluster_name;
+
 	got_jobs_msg.jobs = jobacct_storage_g_get_jobs(
 		db_conn,
 		get_jobs_msg->selected_steps, get_jobs_msg->selected_parts,
-- 
GitLab