Cluster: don't let a node forget its own master.

redis-trib should make sure to reconfigure slaves of a node to remove
from the cluster to replicate with other nodes before sending CLUSTER
FORGET.
This commit is contained in:
antirez 2014-01-16 17:49:35 +01:00
parent 9531c84807
commit 3d455393a6

View File

@ -2875,12 +2875,16 @@ void clusterCommand(redisClient *c) {
/* CLUSTER FORGET <NODE ID> */
clusterNode *n = clusterLookupNode(c->argv[2]->ptr);
if (n == server.cluster->myself) {
addReplyErrorFormat(c,"I tried hard but I can't forget myself...");
return;
} else if (!n) {
if (!n) {
addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr);
return;
} else if (n == server.cluster->myself) {
addReplyError(c,"I tried hard but I can't forget myself...");
return;
} else if (server.cluster->myself->flags & REDIS_NODE_SLAVE &&
server.cluster->myself->slaveof == n) {
addReplyError(c,"Can't forget my master!");
return;
}
clusterBlacklistAddNode(n);
clusterDelNode(n);