From 839461bc62418ce3e8edc22b12856f4e7c5c1b76 Mon Sep 17 00:00:00 2001
From: Marshall Garey <marshall@schedmd.com>
Date: Mon, 10 Jan 2022 12:58:46 -0700
Subject: [PATCH] Fatal if more than one burst buffer plugin is configured

Without this commit, multiple burst buffer plugins could be configured
and would run, but because of both plugins manipulating shared state
(such as job state) this does not work properly and can exhibit
unexpected behavior.

Bug 12125
---
 NEWS                         |  1 +
 RELEASE_NOTES                |  1 +
 src/slurmctld/burst_buffer.c | 11 +++++++++++
 3 files changed, 13 insertions(+)

diff --git a/NEWS b/NEWS
index 12303ef4c2f..6ebfdd86b8c 100644
--- a/NEWS
+++ b/NEWS
@@ -172,6 +172,7 @@ documents those changes that are of interest to users and administrators.
     option has long been obsolete.
  -- cons_tres - change definition of the "least loaded node" (LLN) to the
     node with the greatest ratio of available cpus to total cpus.
+ -- Fatal if more than one burst buffer plugin is configured.
 
 * Changes in Slurm 21.08.7
 ==========================
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index 69d23cd5803..9d15630f5d8 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -74,6 +74,7 @@ CONFIGURATION FILE CHANGES (see man appropriate man page for details)
     jobs within the same qos.
  -- Fatal error if CgroupReleaseAgentDir is configured in cgroup.conf. The
     option has long been obsolete.
+ -- Fatal if more than one burst buffer plugin is configured.
 
 COMMAND CHANGES (see man pages for details)
 ===========================================
diff --git a/src/slurmctld/burst_buffer.c b/src/slurmctld/burst_buffer.c
index 612b8ed66c6..714b45e8b41 100644
--- a/src/slurmctld/burst_buffer.c
+++ b/src/slurmctld/burst_buffer.c
@@ -166,6 +166,17 @@ extern int bb_g_init(void)
 	}
 	init_run = true;
 
+	/*
+	 * Although the burst buffer plugin interface was designed to support
+	 * multiple burst buffer plugins, this currently does not work. For
+	 * now, do not allow multiple burst buffer plugins to be configured.
+	 */
+	if (g_context_cnt > 1) {
+		error("%d burst buffer plugins configured; can not run with more than one burst buffer plugin",
+		      g_context_cnt);
+		rc = SLURM_ERROR;
+	}
+
 fini:
 	slurm_mutex_unlock(&g_context_lock);
 
-- 
GitLab