Commit bd1d5b1a authored by Łukasz Nowak's avatar Łukasz Nowak

slapos_pdm: Support Hosting Subscription with many root Software Instances

Since during maintenance of Hosting Subscription it's possible to end up with
many root Software Instances (of which many might be destroy_requested) it's
needed to support such situation while creating upgrade decision and finding
upgradeable Software Release.
parent 54c18e60
Pipeline #15636 failed with stage
in 0 seconds
......@@ -6,9 +6,12 @@ upgrade_scope = context.getUpgradeScope()
if upgrade_scope in ["never", "disabled"]:
return
root_instance = hosting_subscription.getPredecessorValue(portal_type=["Software Instance", "Slave Instance"])
if root_instance is None:
root_instance_list = [
q for q in hosting_subscription.getPredecessorValueList(portal_type=["Software Instance", "Slave Instance"])
if q.getSlapState() != 'destroy_requested']
if len(root_instance_list) == 0:
return
root_instance = root_instance_list[0]
slave_upgrade = False
if root_instance.getPortalType() == 'Slave Instance':
......
......@@ -11,9 +11,10 @@ slap_state = ['start_requested', 'stop_requested']
if not hosting_subscription.getSlapState() in slap_state:
return None
source_instance = hosting_subscription.getPredecessorValue()
if not source_instance or source_instance.getSlapState() not in slap_state:
source_instance_list = [q for q in hosting_subscription.getPredecessorValueList() if q.getSlapState() in slap_state]
if len(source_instance_list) == 0:
return None
source_instance = source_instance_list[0]
software_release = hosting_subscription.HostingSubscription_getNewerSofwareRelease()
if not software_release:
......
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