moby: Error trying to remove dead nodes from swarm: raft message is too large and can't be sent
I have a swarm with ~1300 nodes, and some enter and leave all the time (about 10/minute).
Since about a week ago, I’m experiencing an error when trying to remove dead nodes with docker node rm xxxx from the swarm:
Error response from daemon: rpc error: code = Unknown desc = raft: raft message is too large and can't be sent
All I see in the logs is the same:
Apr 5 12:35:31 ip-10-0-0-10 dockerd[1239]: time="2018-04-05T12:35:31.686809606Z" level=error msg="Error removing node x2nhsvmnzoaq5hp3xqfl2a7dp: rpc error: code = Unknown desc = raft: raft message is too large and can't be sent"
Apr 5 12:35:31 ip-10-0-0-10 dockerd[1239]: time="2018-04-05T12:35:31.687236652Z" level=error msg="Handler for DELETE /v1.37/nodes/x2nhsvmnzoaq5hp3xqfl2a7dp returned error: rpc error: code = Unknown desc = raft: raft message is too large and can't be sent"
Apr 5 12:35:36 ip-10-0-0-10 dockerd[1239]: time="2018-04-05T12:35:36.289574281Z" level=error msg="Error removing node kdmprxylwjmvutsfb9y1f2o17: rpc error: code = Unknown desc = raft: raft message is too large and can't be sent"
Apr 5 12:35:36 ip-10-0-0-10 dockerd[1239]: time="2018-04-05T12:35:36.289644704Z" level=error msg="Handler for DELETE /v1.37/nodes/kdmprxylwjmvutsfb9y1f2o17 returned error: rpc error: code = Unknown desc = raft: raft message is too large and can't be sent"
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 17 (8 by maintainers)
@eduardolundgren the root cause of your issue is very different, but I know what the problem is. I’m opening an issue on swarmkit, docker/swarmkit#2655
I think I might know what the root cause of this is:
When a swarm node is removed, we add it to a certificate blacklist, so that node ID cannot be reused until its certificate would expire. Those blacklisted certificates live in the Cluster object. I think that this list has just grown and grown to the point where the Cluster object has grown larger than the maximum message size (roughly 1.5 megabytes).
Some quick napkin math: The cert blacklist is composed of the node ID (a string) and a Timestamp. Altogether it would be about 37 bytes, roughly. There is other information in the Cluster object as well, but ignoring that, if you got to somewhere in the neighborhood of 42,000 successfully removed nodes over the entire lifetime of the cluster, you might break the upper limit.
I can work on a quick program to verify that this is the problem, if you think there’s no way you churned through 42,000 nodes already. If it sounds like you might have already hit that limit though, then that’s the likely problem. Unfortunately the only way to get the exact cert blacklist size would be to write a custom client for the swarmkit control api, connect through the swarmkit control socket, and count the blacklist size that way, which is a pain in the butt and why I haven’t already given you a program to do this.
The bad news is, assuming this is the case (there’s a non-zero chance it’s some other cause), we don’t have an answer for what to do right now. The default certificate expiry time is 3 months, and after it’s exceed, when you try to remove a node, it will also remove any expired blacklist entries and allow the message size to get small enough to go through. Other than waiting, though, there’s no way to force nodes off the blacklist.
However, there is a more permanent fix:
Assuming a peak throughput of 10 removed nodes per minute, just about 70 hours of peak usage is enough to exceed the magic number of 42000 nodes that we think could be causing this. You probably aren’t experiencing maximum throughput at all times, so you’ll have to figure out how long it takes you to exceed the capacity. Once you have that duration, you can set the swarmkit certificate expiry time to less than that value with this command:
(docs: https://docs.docker.com/engine/reference/commandline/swarm_ca/#usage)
Swarm will set the expiry time to this value, and when you do a
docker node rm, if there are any nodes in the blacklist that would have expired, they’ll be removed as part of node removal. This will keep the blacklist under the size at which it would prevent removing more nodes.The side effect is that your cluster will rotate its certificates much more frequently (typically, rotation is every 3 months). On the other hand, if your whole cluster is churning, then it’s like that the vast majority of nodes won’t ever even live long enough to see a certificate rotation, so it shouldn’t be that impactful.
Again, this is based off educated speculation, so there’s a possibility that this RCA is totally wrong, but this is the most likely cause without getting hands directly on your cluster. WDYT?