Commit 307e1012 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Stop orphans on SoftwareInstance_tryToStopCollect

    In case the instance isn't linked to the tree properly (due Garbage Collect unlinked it), stop the instance directly anyway.
parent 6009bdf0
Pipeline #19507 failed with stage
in 0 seconds
...@@ -4,14 +4,12 @@ if REQUEST is not None: ...@@ -4,14 +4,12 @@ if REQUEST is not None:
instance = context instance = context
if (instance.getSlapState() == "start_requested"): if instance.getSlapState() != "start_requested":
instance_tree = instance.getSpecialiseValue(portal_type="Instance Tree") # Only continue if the instance is started
if (instance_tree.getSlapState() == "stop_requested"): return
# Buildout may not propagate the stop request
requester = instance.getSuccessorRelatedValue() instance_tree = instance.getSpecialiseValue(portal_type="Instance Tree")
if (instance.getRelativeUrl() in requester.getSuccessorList()) and \ if (instance_tree.getSlapState() == "stop_requested"):
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
if instance.getPortalType() == 'Software Instance': if instance.getPortalType() == 'Software Instance':
is_slave = False is_slave = False
...@@ -21,6 +19,21 @@ if (instance.getSlapState() == "start_requested"): ...@@ -21,6 +19,21 @@ if (instance.getSlapState() == "start_requested"):
raise NotImplementedError, "Unknown portal type %s of %s" % \ raise NotImplementedError, "Unknown portal type %s of %s" % \
(instance.getPortalType(), instance.getRelativeUrl()) (instance.getPortalType(), instance.getRelativeUrl())
# Buildout may not propagate the stop request
requester = instance.getSuccessorRelatedValue()
if requester is None:
# Instance is orphan, so it stops itself.
instance.requestStop(
software_release=instance.getUrlString(),
software_type=instance.getSourceReference(),
instance_xml=instance.getTextContent(),
sla_xml=instance.getSlaXml(),
shared=is_slave,
comment="Stop collect %s" % instance.getRelativeUrl())
else:
if (instance.getRelativeUrl() in requester.getSuccessorList()) and \
(requester.getSlapState() == "stop_requested"):
# For security, only stop if parent is also stopped
requester.requestInstance( requester.requestInstance(
software_release=instance.getUrlString(), software_release=instance.getUrlString(),
software_title=instance.getTitle(), software_title=instance.getTitle(),
......
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