Skip to content
Snippets Groups Projects
Commit a8b2e459 authored by Nicolas Dandrimont's avatar Nicolas Dandrimont
Browse files

winery rbd shard mapper: randomize shards

This reduces contention across parallel processes (if they act on
overlapping shards): a crash can happen if two rbd processes call `rbd
map` on the same shard at the same time.
parent ece77d05
No related branches found
No related tags found
1 merge request!214Winery settings refactorings
......@@ -7,6 +7,7 @@ from collections import Counter
import logging
import math
import os
import random
import shlex
import socket
import stat
......@@ -230,6 +231,7 @@ class Pool(object):
for shard_name, shard_state in base.list_shards()
if not only_prefix or shard_name.startswith(only_prefix)
]
random.shuffle(shards)
if logger.isEnabledFor(logging.DEBUG):
logger.debug(
"Listed %d shards in %.02f seconds",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment