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
Boxiang Sun
slapos.core
Commits
7147e993
Commit
7147e993
authored
Oct 07, 2016
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: check more before destroy instance without parent
parent
a6caed19
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
9 deletions
+42
-9
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_garbageCollectDestroyUnlinkedInstance.py
...apos_cloud/Alarm_garbageCollectDestroyUnlinkedInstance.py
+1
-1
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
...os_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
+21
-7
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+20
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Alarm_garbageCollectDestroyUnlinkedInstance.py
View file @
7147e993
...
...
@@ -5,7 +5,7 @@ portal.portal_catalog.searchAndActivate(
portal_type
=
[
"Software Instance"
,
"Slave Instance"
],
validation_state
=
"validated"
,
specialise_validation_state
=
"validated"
,
predecessor_related_
title
=
SimpleQuery
(
predecessor_related_title
=
None
,
comparison_operator
=
'is'
),
predecessor_related_
uid
=
SimpleQuery
(
predecessor_related_uid
=
None
,
comparison_operator
=
'is'
),
method_id
=
'SoftwareInstance_tryToGarbageUnlinkedInstance'
,
activate_kw
=
{
'tag'
:
tag
}
)
...
...
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/SoftwareInstance_tryToGarbageUnlinkedInstance.py
View file @
7147e993
...
...
@@ -6,6 +6,20 @@ if REQUEST is not None:
instance
=
context
def
checkInstanceTree
(
instance_list
):
"""
Check if predecessor link is really removed to this instance
"""
sub_instance_list
=
[]
if
instance_list
==
[]:
return
for
item
in
instance_list
:
if
item
.
getUid
()
==
instance
.
getUid
():
return
item
sub_instance_list
.
extend
(
item
.
getPredecessorValueList
())
return
checkInstanceTree
(
sub_instance_list
)
if
instance
.
getSlapState
()
==
"destroy_requested"
:
return
...
...
@@ -14,18 +28,18 @@ if hosting_subscription is None or \
hosting_subscription
.
getSlapState
()
==
"destroy_requested"
:
return
root_instance
=
hosting_subscription
.
getPredecessorValue
()
if
root_instance
is
None
:
# Refuse to destroy root instance
raise
ValueError
(
"Hosting Subscription %s has no root instance, this should "
\
"not happen!!"
%
hosting_subscription
.
getRelativeUrl
())
# If instance modificationDate is too recent, skip
# Delay destroy of unlinked instances
if
not
delay_time
:
delay_time
=
50
if
instance
.
getModificationDate
()
-
addToDate
(
DateTime
(),
{
'minute'
:
-
1
*
delay_time
})
>
0
:
return
if
hosting_subscription
.
getTitle
()
==
instance
.
getTitle
():
# Refuse to destroy root instance
return
if
instance
.
getPredecessorRelatedValue
()
is
None
:
if
checkInstanceTree
([
root_instance
])
is
None
:
# This unlinked instance to parent should be removed
is_slave
=
False
if
instance
.
getPortalType
()
==
'Slave Instance'
:
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
7147e993
...
...
@@ -2191,10 +2191,29 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
tic
()
self
.
assertEqual
(
instance
.
getPredecessorRelatedTitle
(),
None
)
# will not destroy
instance
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
10
)
self
.
assertRaises
(
ValueError
,
instance
.
SoftwareInstance_tryToGarbageUnlinkedInstance
,
delay_time
=-
10
)
self
.
tic
()
self
.
assertEqual
(
instance
.
getSlapState
(),
'start_requested'
)
def
test_SoftwareInstance_tryToGarbageUnlinkedInstance_not_unlinked
(
self
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputerPartition
()
instance
.
edit
(
aggregate_value
=
partition
)
self
.
tic
()
instance0
=
self
.
doRequestInstance
(
instance
,
'instance0'
)
instance_instance0
=
self
.
doRequestInstance
(
instance0
,
'Subinstance0'
)
self
.
assertEqual
(
instance_instance0
.
getPredecessorRelatedTitle
(),
'instance0'
)
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
# Try to remove without delete predecessor link
instance_instance0
.
SoftwareInstance_tryToGarbageUnlinkedInstance
(
delay_time
=-
1
)
self
.
tic
()
self
.
assertEqual
(
instance_instance0
.
getSlapState
(),
'start_requested'
)
def
test_alarm_search_inlinked_instance
(
self
):
instance
=
self
.
createInstance
()
partition
=
self
.
createComputerPartition
()
...
...
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