From cd25e7e738072921d0aa5f3639653aec9ca09f13 Mon Sep 17 00:00:00 2001
From: Brian Christiansen <brian@schedmd.com>
Date: Thu, 7 Jul 2016 00:09:03 -0600
Subject: [PATCH] Send empty fed list to signal clusters of removal from fed

---
 .../accounting_storage/mysql/as_mysql_federation.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/plugins/accounting_storage/mysql/as_mysql_federation.c b/src/plugins/accounting_storage/mysql/as_mysql_federation.c
index 3ce5f9942c1..4f10406f046 100644
--- a/src/plugins/accounting_storage/mysql/as_mysql_federation.c
+++ b/src/plugins/accounting_storage/mysql/as_mysql_federation.c
@@ -693,12 +693,16 @@ extern List as_mysql_remove_federations(mysql_conn_t *mysql_conn, uint32_t uid,
 
 extern int as_mysql_add_feds_to_update_list(mysql_conn_t *mysql_conn)
 {
-	int rc = SLURM_SUCCESS;
+	int rc = SLURM_ERROR;
 	List feds = as_mysql_get_federations(mysql_conn, 0, NULL);
-	if (feds && list_count(feds)) {
-		if ((rc = addto_update_list(mysql_conn->update_list,
-				       SLURMDB_UPDATE_FEDS, feds))
-		    != SLURM_SUCCESS)
+
+	/* Even if there are no feds, need to send an empty list for the case
+	 * that all feds were removed. The controller needs to know that it was
+	 * removed from a federation. */
+	if (feds &&
+	    ((rc = addto_update_list(mysql_conn->update_list,
+				     SLURMDB_UPDATE_FEDS, feds))
+	     != SLURM_SUCCESS)) {
 			FREE_NULL_LIST(feds);
 	}
 	return rc;
-- 
GitLab