From abf06fd5ff27be9d73e39c1e6bd53e8e47c528a9 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Thu, 7 Mar 2013 15:22:32 +0100
Subject: [PATCH] Cluster: log global cluster state change.

---
 src/cluster.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/cluster.c b/src/cluster.c
index 27c1f55a4..df0a22845 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -1450,7 +1450,7 @@ int clusterDelSlot(int slot) {
  * Cluster state evaluation function
  * -------------------------------------------------------------------------- */
 void clusterUpdateState(void) {
-    int j;
+    int j, initial_state = server.cluster->state;
 
     /* Start assuming the state is OK. We'll turn it into FAIL if there
      * are the right conditions. */
@@ -1482,6 +1482,11 @@ void clusterUpdateState(void) {
         }
         dictReleaseIterator(di);
     }
+
+    /* Log a state change */
+    if (initial_state != server.cluster->state)
+        redisLog(REDIS_WARNING,"Cluster state changed: %s",
+            server.cluster->state == REDIS_CLUSTER_OK ? "ok" : "fail");
 }
 
 /* This function is called after the node startup in order to verify that data