Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
slapos.core
Commits
c8fd80f8
Commit
c8fd80f8
authored
Apr 05, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: reduce the number of alarm calls
parent
8cf975dc
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
533 additions
and
30 deletions
+533
-30
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.py
...em/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.py
+31
-20
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.xml
...m/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.xml
+1
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudSkins.py
...eItem/portal_components/test.erp5.testSlapOSCloudSkins.py
+367
-0
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudSkins.xml
...Item/portal_components/test.erp5.testSlapOSCloudSkins.xml
+124
-0
master/bt5/slapos_cloud/bt/template_test_id_list
master/bt5/slapos_cloud/bt/template_test_id_list
+10
-9
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.py
View file @
c8fd80f8
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
portal
=
context
.
getPortalObject
()
portal
=
context
.
getPortalObject
()
alarm_tool
=
portal
.
portal_alarms
alarm_tool
=
portal
.
portal_alarms
# Higher than simulable movement priority
# Higher than simulable movement priority
PRIORITY
=
4
# priority=3, to be executed after all reindex, but also execute simulation _expand
PRIORITY
=
3
if
alarm_tool
.
isSubscribed
()
and
len
(
alarm_id_list
):
if
alarm_tool
.
isSubscribed
()
and
len
(
alarm_id_list
):
# No alarm tool is not subscribed, respect this choice and do not activate any alarm
# No alarm tool is not subscribed, respect this choice and do not activate any alarm
...
@@ -14,6 +19,8 @@ if alarm_tool.isSubscribed() and len(alarm_id_list):
...
@@ -14,6 +19,8 @@ if alarm_tool.isSubscribed() and len(alarm_id_list):
for
alarm_id
in
alarm_id_list
:
for
alarm_id
in
alarm_id_list
:
alarm
=
alarm_tool
.
restrictedTraverse
(
alarm_id
)
alarm
=
alarm_tool
.
restrictedTraverse
(
alarm_id
)
deduplication_tag
=
'Base_reindexAndSenseAlarm_%s'
%
alarm_id
if
alarm
.
isEnabled
():
if
alarm
.
isEnabled
():
# do nothing if the alarm is not enabled
# do nothing if the alarm is not enabled
...
@@ -21,24 +28,28 @@ if alarm_tool.isSubscribed() and len(alarm_id_list):
...
@@ -21,24 +28,28 @@ if alarm_tool.isSubscribed() and len(alarm_id_list):
activate_kw
=
{}
activate_kw
=
{}
activate_kw
[
'activity'
]
=
'SQLQueue'
activate_kw
[
'activity'
]
=
'SQLQueue'
activate_kw
[
'after_tag'
]
=
tag
activate_kw
[
'after_tag'
]
=
tag
# Wait for the previous alarm run to be finished
activate_kw
[
'tag'
]
=
deduplication_tag
context
.
activate
(
**
activate_kw
).
Base_reindexAndSenseAlarm
([
alarm_id
],
activate_kw
[
'priority'
]
=
max
(
1
,
PRIORITY
-
1
)
must_reindex_context
=
False
)
# Wait for the context indexation to be finished
elif
alarm
.
isActive
():
activate_kw
=
{}
activate_kw
[
'priority'
]
=
PRIORITY
activate_kw
[
'after_path_and_method_id'
]
=
(
alarm
.
getPath
(),
'getId'
)
# Wait for the previous alarm run to be finished
# call on alarm tool to gather and drop with sqldict
alarm_tool
.
activate
(
**
activate_kw
).
Base_reindexAndSenseAlarm
([
alarm_id
],
alarm_tool
.
activate
(
**
activate_kw
).
Base_reindexAndSenseAlarm
([
alarm_id
],
must_reindex_context
=
False
)
must_reindex_context
=
False
)
else
:
# Do not call directly call activeSense, because in case of concurrency,
elif
portal
.
portal_activities
.
countMessageWithTag
(
deduplication_tag
)
<=
1
:
# it will trigger the alarm multiple time in parallel
if
alarm
.
isActive
():
# Wait for the previous alarm run to be finished
# If the alarm is active, wait for it
# wait for the context to be reindexed before activating the alarm
# and try to reduce the number of activities
# ROMAIN: getId is used, because most alarm script ends with an getId activity
# to reduce the number of alarm execution
# priority=3, to be executed after all reindex, but also execute simulation _expand
activate_kw
=
{}
alarm
.
activate
(
priority
=
PRIORITY
).
activeSense
()
activate_kw
[
'activity'
]
=
'SQLQueue'
# Prevent 2 nodes to call activateSense concurrently
activate_kw
[
'priority'
]
=
PRIORITY
alarm
.
serialize
()
activate_kw
[
'tag'
]
=
deduplication_tag
activate_kw
[
'after_path'
]
=
alarm
.
getPath
()
# Wait for the previous alarm run to be finished
# call on alarm tool to gather and drop with sqldict
alarm_tool
.
activate
(
**
activate_kw
).
Base_reindexAndSenseAlarm
([
alarm_id
],
must_reindex_context
=
False
)
else
:
# activeSense create an activity in SQLDict
alarm
.
activeSense
()
# Prevent 2 nodes to call activateSense concurrently
alarm
.
serialize
()
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Base_reindexAndSenseAlarm.xml
View file @
c8fd80f8
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
_params
</string>
</key>
<key>
<string>
_params
</string>
</key>
<value>
<string>
alarm_id_list, must_reindex_context=True
</string>
</value>
<value>
<string>
alarm_id_list, must_reindex_context=True
, REQUEST=None
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudSkins.py
0 → 100644
View file @
c8fd80f8
This diff is collapsed.
Click to expand it.
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudSkins.xml
0 → 100644
View file @
c8fd80f8
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testSlapOSCloudSkins
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testSlapOSCloudSkins
</string>
</value>
</item>
<item>
<key>
<string>
language
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_cloud/bt/template_test_id_list
View file @
c8fd80f8
test.erp5.testSlapOSCloudAlarm
test.erp5.SlapOSTestCaseDefaultScenarioMixin
test.erp5.SlapOSTestCaseMixin
test.erp5.testSlapOSAllocationSupply
test.erp5.testSlapOSAllocationSupply
test.erp5.testSlapOSCloud
test.erp5.testSlapOSCloudAlarm
test.erp5.testSlapOSCloudAllocationAlarm
test.erp5.testSlapOSCloudAllocationAlarm
test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputePartitionSlapInterfaceWorkflow
test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInteractionWorkflow
test.erp5.testSlapOSCloudInteractionWorkflow
test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow
test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow
test.erp5.testSlapOSCloudNetworkSlapInterfaceWorkflow
test.erp5.testSlapOSCloudComputeNodeSlapInterfaceWorkflow
test.erp5.testSlapOSCloudPersonSlapInterfaceWorkflow
test.erp5.testSlapOSCloudInstanceSlapInterfaceWorkflow
test.erp5.testSlapOSCloudProjectSlapInterfaceWorkflow
test.erp5.testSlapOSCloudProjectSlapInterfaceWorkflow
test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudSecurityGroup
test.erp5.testSlapOSCloudConstraint
test.erp5.testSlapOSCloudUpgrader
test.erp5.testSlapOSCloudShadow
test.erp5.testSlapOSCloudShadow
test.erp5.SlapOSTestCaseMixin
test.erp5.testSlapOSCloudSkins
test.erp5.SlapOSTestCaseDefaultScenarioMixin
test.erp5.testSlapOSCloudUpgrader
test.erp5.testSlapOSCloud
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment