Commit 88e13a1a authored by Romain Courteaud's avatar Romain Courteaud 🐙

slapos_cloud: fix script_ComputeNode_reportBang unauthorized error

No need to access invalidated instances.

Also try to reduce conflict, and try to not block indexation activities.
parent df6d89b7
compute_node = state_change['object']
portal = compute_node.getPortalObject()
for compute_partition in [x for x in compute_node.contentValues(portal_type='Compute Partition') if x.getSlapState() == 'busy']:
for instance_sql in portal.portal_catalog(
default_aggregate_uid=compute_partition.getUid(),
portal_type=["Software Instance", "Slave Instance"],
):
instance = instance_sql.getObject()
if instance.getSlapState() in ["start_requested", "stop_requested"]:
instance.activate().SoftwareInstance_bangAsSelf(
relative_url=instance.getRelativeUrl(),
reference=instance.getReference(),
comment=state_change.kwargs.get('comment', ''))
compute_partition_uid_list = [x.getUid() for x in compute_node.contentValues(portal_type='Compute Partition') if x.getSlapState() == 'busy']
for instance_sql in portal.portal_catalog(
default_aggregate_uid=compute_partition_uid_list,
portal_type=["Software Instance", "Slave Instance"],
validation_state='validated',
# Try limiting conflicts on multiple instances of the same tree
# example: monitor frontend
group_by_list=['specialise_uid']
):
instance = instance_sql.getObject()
if instance.getSlapState() in ["start_requested", "stop_requested"]:
# Increase priority to not block indexations
# if there are many activities created
instance.activate(priority=2).SoftwareInstance_bangAsSelf(
relative_url=instance.getRelativeUrl(),
reference=instance.getReference(),
comment=state_change.kwargs.get('comment', '')
)
compute_node.setErrorStatus('bang')
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