Commit 8aa976ca authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: reduce the risk of always allocating on the same node

parent f6f4ab05
...@@ -171,7 +171,7 @@ if test_mode: ...@@ -171,7 +171,7 @@ if test_mode:
SQL_WINDOW_SIZE = 50 SQL_WINDOW_SIZE = 50
# fetch at mot 50 random Compute Partitions, and check if they are ok # fetch at most 50 random Compute Partitions, and check if they are ok
isTransitionPossible = portal.portal_workflow.isTransitionPossible isTransitionPossible = portal.portal_workflow.isTransitionPossible
result_count = portal.portal_catalog.countResults(**query_kw)[0][0] result_count = portal.portal_catalog.countResults(**query_kw)[0][0]
offset = max(0, result_count-1) offset = max(0, result_count-1)
...@@ -180,8 +180,12 @@ if offset >= SQL_WINDOW_SIZE: ...@@ -180,8 +180,12 @@ if offset >= SQL_WINDOW_SIZE:
else: else:
limit = (0, SQL_WINDOW_SIZE) limit = (0, SQL_WINDOW_SIZE)
for compute_partition_candidate in portal.portal_catalog( compute_partition_candidate_list = [x for x in portal.portal_catalog(limit=limit, **query_kw)]
limit=limit, **query_kw): # reduce risk of always allocating on the same node
# (in case of slave instance for example)
random.shuffle(compute_partition_candidate_list)
for compute_partition_candidate in compute_partition_candidate_list:
compute_partition_candidate = compute_partition_candidate.getObject() compute_partition_candidate = compute_partition_candidate.getObject()
if compute_partition_candidate.getParentValue().getCapacityScope() == "close": if compute_partition_candidate.getParentValue().getCapacityScope() == "close":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment