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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
ef1cc06d
Commit
ef1cc06d
authored
Nov 15, 2023
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: invalidate Slave Instance allocation on a Compute Node
parent
41e5b151
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
4 deletions
+62
-4
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToInvalidateIfDestroyed.py
...apos_cloud/SoftwareInstance_tryToInvalidateIfDestroyed.py
+14
-4
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+48
-0
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToInvalidateIfDestroyed.py
View file @
ef1cc06d
...
...
@@ -6,7 +6,17 @@ if context.getPortalType() not in ('Software Instance', 'Slave Instance'):
raise
TypeError
(
'%s is not supported'
%
context
.
getPortalType
())
software_instance
=
context
if
software_instance
.
getValidationState
()
==
'validated'
\
and
software_instance
.
getSlapState
()
==
'destroy_requested'
\
and
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
)
is
None
:
software_instance
.
invalidate
(
comment
=
'Invalidated as unallocated and destroyed'
)
if
(
software_instance
.
getValidationState
()
==
'validated'
)
\
and
(
software_instance
.
getSlapState
()
==
'destroy_requested'
):
partition
=
software_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
)
if
partition
is
None
:
software_instance
.
invalidate
(
comment
=
'Invalidated as unallocated and destroyed'
)
elif
(
partition
.
getParentValue
().
getPortalType
()
==
'Compute Node'
)
and
\
(
software_instance
.
getPortalType
()
==
'Slave Instance'
):
# Invalidate ONLY IF the partition is inside a Compute Node, which does not report destruction
software_instance
.
invalidate
(
comment
=
'Invalidated as Compute Node does not report destruction of Slave Instance'
)
# Software Instance allocated on a Compute Node is invalidated by SlapTool
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
ef1cc06d
...
...
@@ -1201,6 +1201,54 @@ class TestSlapOSInvalidateDestroyedInstance(SlapOSTestCaseMixin):
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
def
test_tryToInvalidateIfDestroyed_script_allocatedSlaveInstance
(
self
):
instance_tree
=
self
.
addInstanceTree
(
shared
=
True
)
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
())
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"invalidated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
def
test_tryToInvalidateIfDestroyed_script_allocatedInstanceOnRemoteNode
(
self
):
instance_tree
=
self
.
addInstanceTree
()
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
(),
portal_type
=
"Remote Node"
)
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
def
test_tryToInvalidateIfDestroyed_script_allocatedSlaveInstanceOnRemoteNode
(
self
):
instance_tree
=
self
.
addInstanceTree
(
shared
=
True
)
software_instance
=
instance_tree
.
getSuccessorValue
()
_
,
partition
=
self
.
addComputeNodeAndPartition
(
project
=
instance_tree
.
getFollowUpValue
(),
portal_type
=
"Remote Node"
)
software_instance
.
setAggregateValue
(
partition
)
partition
.
markBusy
()
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'validated'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
software_instance
,
'destroy_requested'
)
software_instance
.
SoftwareInstance_tryToInvalidateIfDestroyed
()
self
.
assertEqual
(
software_instance
.
getValidationState
(),
"validated"
)
self
.
assertEqual
(
software_instance
.
getSlapState
(),
"destroy_requested"
)
class
TestSlapOSPropagateRemoteNodeInstance
(
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