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
Titouan Soulard
slapos.core
Commits
8b41d4fd
Commit
8b41d4fd
authored
Sep 11, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: reduce number of accessed instances
parent
37f8f7ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
7 deletions
+51
-7
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
...s/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
+10
-6
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+41
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/ComputeNode_checkAndUpdateCapacityScope.py
View file @
8b41d4fd
...
...
@@ -59,20 +59,24 @@ if can_allocate:
return
type_variation
.
getCapacityQuantity
(
1
)
if
allocated_instance
is
not
None
:
software_release_capacity
=
getSoftwareReleaseCapacity
(
allocated_instance
)
consumed_capacity
+=
software_release_capacity
consumed_capacity
+=
getSoftwareReleaseCapacity
(
allocated_instance
)
if
consumed_capacity
>=
compute_node_capacity_quantity
:
can_allocate
=
False
comment
=
'Compute Node capacity limit exceeded (%s >= %s)'
%
(
consumed_capacity
,
compute_node_capacity_quantity
)
if
can_allocate
:
for
instance
in
portal
.
portal_catalog
.
portal_catalog
(
for
sql_
instance
in
portal
.
portal_catalog
.
portal_catalog
(
default_aggregate_relative_url
=
'%s/%%'
%
compute_node
.
getRelativeUrl
(),
portal_type
=
[
'Software Instance'
,
'Slave Instance'
],
validation_state
=
'validated'
):
validation_state
=
'validated'
,
group_by
=
[
'url_string'
,
'source_reference'
],
select_list
=
[
'COUNT(*)'
,
'url_string'
,
'source_reference'
]
):
software_release_capacity
=
getSoftwareReleaseCapacity
(
instance
.
getObject
())
consumed_capacity
+=
software_release_capacity
assert
sql_instance
.
url_string
==
sql_instance
.
getUrlString
()
assert
sql_instance
.
source_reference
==
sql_instance
.
getSourceReference
()
assert
1
<=
sql_instance
[
'COUNT(*)'
]
consumed_capacity
+=
getSoftwareReleaseCapacity
(
sql_instance
)
*
sql_instance
[
'COUNT(*)'
]
if
consumed_capacity
>=
compute_node_capacity_quantity
:
can_allocate
=
False
comment
=
'Compute Node capacity limit exceeded'
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
8b41d4fd
...
...
@@ -632,7 +632,6 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
compute_node
.
setAccessStatus
(
"#access ok"
)
type_variation
.
setCapacityQuantity
(
9999999999999
)
compute_node
.
log
(
type_variation
)
self
.
tic
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
...
...
@@ -640,6 +639,47 @@ class TestSlapOSUpdateComputeNodeCapacityScopeAlarm(SlapOSTestCaseMixin):
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_ComputeNode_checkAndUpdateCapacityScope_script_softwareProductCapacityMultipleInstance
(
self
):
_
,
_
,
type_variation
,
compute_node
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
allocation_state
=
'allocated'
)
compute_node
.
setAccessStatus
(
"#access ok"
)
compute_node
.
edit
(
capacity_quantity
=
6
)
type_variation
.
setCapacityQuantity
(
3
)
self
.
tic
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'open'
,
compute_node
.
getCapacityScope
())
partition
=
compute_node
.
newContent
(
portal_type
=
'Compute Partition'
,
reference
=
'reference%s'
%
self
.
generateNewId
()
)
partition
.
validate
()
partition
.
markFree
()
self
.
tic
()
with
TemporaryAlarmScript
(
self
.
portal
,
'Item_getSubscriptionStatus'
,
"'subscribed'"
):
instance_tree
.
getDestinationSectionValue
().
requestSoftwareInstance
(
software_release
=
instance_tree
.
getUrlString
(),
software_type
=
instance_tree
.
getSourceReference
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateEmptyXml
(),
shared
=
False
,
software_title
=
instance_tree
.
getTitle
()
+
'2'
,
state
=
'started'
,
project_reference
=
instance_tree
.
getFollowUpReference
()
)
new_instance
=
self
.
portal
.
REQUEST
.
get
(
'request_instance'
)
new_instance
.
edit
(
aggregate_value
=
partition
)
partition
.
markBusy
()
self
.
tic
()
compute_node
.
ComputeNode_checkAndUpdateCapacityScope
()
self
.
assertEqual
(
'close'
,
compute_node
.
getCapacityScope
())
self
.
assertEqual
(
'Compute Node capacity limit exceeded'
,
compute_node
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
class
TestSlapOSGarbageCollectStoppedRootTreeAlarm
(
SlapOSTestCaseMixin
):
#################################################################
...
...
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