Commit d2926e19 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud:

* reduce some alarms frequency
  Interaction workflow are needed to speed up everything
* add Base_reindexAndSenseAlarm
* add interactions to speed up allocation
  Use Base_reindexAndSenseAlarm, to ensure object is reindexed, in order to be handled by the alarm
* test: no need to manually call alarms
  Interaction workflow will trigger them
* and fix wrong usage of Base_reindexAndSenseAlarm
parent eb6cb588
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>slapos_allocate_instance</string> </value> <value> <string>slapos_allocate_instance</string> </value>
</item> </item>
<item>
<key> <string>periodicity_day_frequency</string> </key>
<value> <int>1</int> </value>
</item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
<value> <value>
...@@ -38,7 +42,9 @@ ...@@ -38,7 +42,9 @@
</item> </item>
<item> <item>
<key> <string>periodicity_minute_frequency</string> </key> <key> <string>periodicity_minute_frequency</string> </key>
<value> <int>1</int> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_month</string> </key> <key> <string>periodicity_month</string> </key>
......
...@@ -30,9 +30,7 @@ ...@@ -30,9 +30,7 @@
</item> </item>
<item> <item>
<key> <string>periodicity_day_frequency</string> </key> <key> <string>periodicity_day_frequency</string> </key>
<value> <value> <int>1</int> </value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_hour</string> </key> <key> <string>periodicity_hour</string> </key>
...@@ -54,7 +52,9 @@ ...@@ -54,7 +52,9 @@
</item> </item>
<item> <item>
<key> <string>periodicity_minute_frequency</string> </key> <key> <string>periodicity_minute_frequency</string> </key>
<value> <int>5</int> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>periodicity_month</string> </key> <key> <string>periodicity_month</string> </key>
...@@ -73,9 +73,11 @@ ...@@ -73,9 +73,11 @@
<value> <value>
<object> <object>
<klass> <klass>
<global name="DateTime" module="DateTime.DateTime"/> <global name="_reconstructor" module="copy_reg"/>
</klass> </klass>
<tuple> <tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/> <none/>
</tuple> </tuple>
<state> <state>
......
portal = context.getPortalObject()
alarm_tool = portal.portal_alarms
if alarm_tool.isSubscribed() and len(alarm_id_list):
# No alarm tool is not subscribed, respect this choice and do not activate any alarm
tag = "%s-%s" % (script.id, context.getRelativeUrl())
if must_reindex_context:
context.reindexObject(activate_kw={'tag': tag})
for alarm_id in alarm_id_list:
alarm = alarm_tool.restrictedTraverse(alarm_id)
if alarm.isEnabled():
# do nothing if the alarm is not enabled
if alarm.isActive():
# Wait for the previous alarm run to be finished
context.activate(after_path=alarm.getPath()).Base_reindexAndSenseAlarm([alarm_id], must_reindex_context=False)
else:
# wait for the context to be reindexed before activating the alarm
# ROMAIN: SQLQueue is used, because I'm not sure if SQLDict drop activities with different after_tag
alarm.activate(queue='SQLQueue', after_tag=tag).activeSense()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>alarm_id_list, must_reindex_context=True</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_reindexAndSenseAlarm</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -292,8 +292,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -292,8 +292,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
finally: finally:
setSecurityManager(sm) setSecurityManager(sm)
self.tic() self.tic()
self.stepCallSlaposFreeComputePartitionAlarm()
self.tic()
free_partition_id_list = [] free_partition_id_list = []
for partition in compute_node.contentValues(portal_type='Compute Partition'): for partition in compute_node.contentValues(portal_type='Compute Partition'):
if partition.getReference() in destroyed_partition_id_list \ if partition.getReference() in destroyed_partition_id_list \
...@@ -371,6 +369,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -371,6 +369,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
instance_title, software_release, software_type, server, instance_title, software_release, software_type, server,
project_reference): project_reference):
self.tic()
self.login(person_user_id) self.login(person_user_id)
self.personRequestInstanceNotReady( self.personRequestInstanceNotReady(
software_release=software_release, software_release=software_release,
...@@ -380,7 +379,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -380,7 +379,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
project_reference=project_reference project_reference=project_reference
) )
self.stepCallSlaposAllocateInstanceAlarm()
self.tic() self.tic()
self.login(person_user_id) self.login(person_user_id)
...@@ -456,9 +454,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -456,9 +454,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
self.assertEqual(408, status) self.assertEqual(408, status)
self.tic() self.tic()
self.stepCallSlaposAllocateInstanceAlarm()
self.tic()
# now instantiate it on compute_node and set some nice connection dict # now instantiate it on compute_node and set some nice connection dict
self.simulateSlapgridCP(server) self.simulateSlapgridCP(server)
...@@ -501,7 +496,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -501,7 +496,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
) )
self.checkServiceSubscriptionRequest(instance_tree) self.checkServiceSubscriptionRequest(instance_tree)
self.stepCallSlaposAllocateInstanceAlarm()
self.tic() self.tic()
self.login(person_user_id) self.login(person_user_id)
...@@ -602,6 +596,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -602,6 +596,7 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
partition_reference=instance_title, partition_reference=instance_title,
project_reference=project_reference project_reference=project_reference
) )
self.tic()
# XXX search only for this user # XXX search only for this user
instance_tree = self.portal.portal_catalog.getResultValue( instance_tree = self.portal.portal_catalog.getResultValue(
...@@ -610,8 +605,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin): ...@@ -610,8 +605,6 @@ class DefaultScenarioMixin(TestSlapOSSecurityMixin):
follow_up__reference=project_reference follow_up__reference=project_reference
) )
self.checkServiceSubscriptionRequest(instance_tree) self.checkServiceSubscriptionRequest(instance_tree)
self.stepCallSlaposAllocateInstanceAlarm()
self.tic() self.tic()
self.login(person_user_id) self.login(person_user_id)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_triggerFreeComputePartitionAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_Instance_invalidate</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Slave Instance</string>
<string>Software Instance</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>invalidate</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_propagateRemoteConnectionXml</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_Instance_setRemoteInstanceConnection</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Software Instance</string>
<string>Slave Instance</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Propagate from remote node</string> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setConnectionXml.*</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Interaction Workflow Interaction" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_triggerPropagateRemoteNodeAlarm</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>interaction_Instance_setRemoteInstanceParameter</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Interaction Workflow Interaction</string> </value>
</item>
<item>
<key> <string>portal_type_filter</string> </key>
<value>
<tuple>
<string>Software Instance</string>
<string>Slave Instance</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type_group_filter</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>temporary_document_disallowed</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Propagate to remote node</string> </value>
</item>
<item>
<key> <string>trigger_method_id</string> </key>
<value>
<tuple>
<string>_setTextContent.*</string>
</tuple>
</value>
</item>
<item>
<key> <string>trigger_once_per_transaction</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
<value> <value>
<tuple> <tuple>
<string>activate_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_triggerAllocationAlarm</string> <string>after_script/portal_workflow/slapos_cloud_interaction_workflow/script_Instance_triggerAllocationAlarm</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
if alarm.getParentValue().isSubscribed() and not alarm.isActive() and alarm.isEnabled():
alarm.activeSense()
instance = state_change['object']
if instance.getTitle().startswith('_remote_'):
return instance.Base_reindexAndSenseAlarm(['slapos_cloud_propagate_remote_node_instance'])
...@@ -50,19 +50,17 @@ ...@@ -50,19 +50,17 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>alarm</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item> <item>
<key> <string>_proxy_roles</string> </key> <key> <string>description</string> </key>
<value> <value>
<tuple> <none/>
<string>Manager</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_Alarm_safeTrigger</string> </value> <value> <string>script_Instance_propagateRemoteConnectionXml</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
software_instance = state_change['object'] return state_change['object'].Base_reindexAndSenseAlarm(['slapos_allocate_instance'])
portal = software_instance.getPortalObject()
if software_instance.getValidationState() == 'validated':
context.Alarm_safeTrigger(portal.portal_alarms.slapos_allocate_instance)
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>state_change</string> </value> <value> <string>state_change</string> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_Instance_triggerAllocationAlarm</string> </value> <value> <string>script_Instance_triggerAllocationAlarm</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Instance_triggerFreeComputePartitionAlarm</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
instance = state_change['object']
partition = instance.getAggregateValue()
if (partition is not None) and (partition.getParentValue().getPortalType() == 'Remote Node'):
partition.Base_reindexAndSenseAlarm(['slapos_cloud_propagate_remote_node_instance'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>script_Instance_triggerPropagateRemoteNodeAlarm</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Script</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
instance = state_change['object'] instance = state_change['object']
partition = instance.getAggregateValue(portal_type="Compute Partition") partition = instance.getAggregateValue(portal_type="Compute Partition")
if partition is not None: if partition is not None:
partition.activate(
after_path_and_method_id=(instance.getPath(), ('immediateReindexObject', 'recursiveImmediateReindexObject'))).reindexObject() active_object = partition.activate(
after_path_and_method_id=(instance.getPath(), ('immediateReindexObject', 'recursiveImmediateReindexObject')))
if partition.getParentValue().getPortalType() == 'Remote Node':
active_object.Base_reindexAndSenseAlarm(['slapos_cloud_propagate_remote_node_instance'])
else:
active_object.reindexObject()
...@@ -60,6 +60,12 @@ ...@@ -60,6 +60,12 @@
</tuple> </tuple>
</value> </value>
</item> </item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>script_SoftwareInstance_reindexComputePartition</string> </value> <value> <string>script_SoftwareInstance_reindexComputePartition</string> </value>
......
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