Commit dc44eb1e authored by Romain Courteaud's avatar Romain Courteaud

slapos_pdm: there could be multiple matching allocation cell for an upgrade

User may have created multiple allocation supplies for the same release/type/node
parent ff6b7fa2
Pipeline #37231 failed with stage
in 0 seconds
......@@ -82,6 +82,18 @@ if (compute_node is None) and (root_instance is not None):
elif (root_instance.getPortalType() == 'Software Instance'):
allocation_cell_list = [x for x, y in allocation_cell_node_list if ("Remote Node" in y) or ("Compute Node" in y)]
# Remove duplicated allocation cells
# ie, multiple allocation cells matching the same release/type/node
software_release_uid_dict = {}
not_duplicated_allocation_cell_list = []
for allocation_cell in allocation_cell_list:
# Do not return duplicated release values
software_release_uid = allocation_cell.getSoftwareReleaseValue().getUid()
if software_release_uid not in software_release_uid_dict:
software_release_uid_dict[software_release_uid] = None
not_duplicated_allocation_cell_list.append(allocation_cell)
allocation_cell_list = not_duplicated_allocation_cell_list
# Only upgrade if there is no doubt (ie, only 1 url is allowed)
if len(allocation_cell_list) == 1:
if (allocation_cell_list[0].getSoftwareReleaseValue().getUrlString() != instance_tree.getUrlString()):
......
......@@ -105,6 +105,22 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(SlapOSTestCaseMixin):
self.assertEqual(None, instance_tree.InstanceTree_createUpgradeDecision())
def test_createUpgradeDecision_notAllocated_newReleaseOnComputeNodeWith2AllocationSupplies(self):
software_product, _, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree()
self.tic()
new_release_variation = self._makeSoftwareRelease(software_product)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.addAllocationSupply("for compute node", compute_node, software_product,
new_release_variation, type_variation, disable_alarm=True)
self.tic()
self.checkCreatedUpgradeDecision(
instance_tree.InstanceTree_createUpgradeDecision(),
instance_tree, software_product, new_release_variation, type_variation
)
def test_createUpgradeDecision_notAllocated_sameRelease(self):
software_product, release_variation, type_variation, compute_node, _, instance_tree = self.bootstrapAllocableInstanceTree()
self.tic()
......
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