Commit b7720e45 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Allow a instance request something out of the it's tree

Due race conditions resilience can unlink instances from a "dead" runner0 to relink it later (on the new runner0). We should allow relink if the instances are active.

This would fix resilience takeover in general.
parent de1b51e4
...@@ -113,11 +113,18 @@ else: ...@@ -113,11 +113,18 @@ else:
# Update the predecessor category of the previous requester # Update the predecessor category of the previous requester
predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance") predecessor = request_software_instance.getPredecessorRelatedValue(portal_type="Software Instance")
if (predecessor is None): if (predecessor is None):
if (requester_instance.getPortalType() != "Hosting Subscription"): # Check if the precessor is a Hosting Subscription
hosting_subscription_precessesor = request_software_instance.getPredecessorRelatedValue(portal_type="Hosting Subscription")
if (requester_instance.getPortalType() != "Hosting Subscription" and hosting_subscription_precessesor is not None):
raise ValueError('It is disallowed to request root software instance %s' % request_software_instance.getRelativeUrl()) raise ValueError('It is disallowed to request root software instance %s' % request_software_instance.getRelativeUrl())
else: else:
predecessor = requester_instance predecessor = requester_instance
# It was a loose node, so check if it ok:
if request_software_instance.getUid() not in graph:
graph[request_software_instance.getUid()] = request_software_instance.getPredecessorUidList()
predecessor_uid_list = predecessor.getPredecessorUidList() predecessor_uid_list = predecessor.getPredecessorUidList()
if request_software_instance.getUid() in predecessor_uid_list:
predecessor_uid_list.remove(request_software_instance.getUid()) predecessor_uid_list.remove(request_software_instance.getUid())
predecessor.edit(predecessor_uid_list=predecessor_uid_list) predecessor.edit(predecessor_uid_list=predecessor_uid_list)
graph[predecessor.getUid()] = predecessor_uid_list graph[predecessor.getUid()] = predecessor_uid_list
......
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