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
Labels
Merge Requests
21
Merge Requests
21
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
b81c9725
Commit
b81c9725
authored
Aug 23, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: Remove old unallocated instances if Allocation is disallowed
parent
912d4117
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Instance_tryToGarbageCollectNonAllocatedRootTree.py
...cloud/Instance_tryToGarbageCollectNonAllocatedRootTree.py
+1
-1
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
...eItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
+65
-1
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Instance_tryToGarbageCollectNonAllocatedRootTree.py
View file @
b81c9725
...
...
@@ -11,7 +11,7 @@ if instance.getValidationState() != 'validated' \
return
latest_comment
=
portal
.
portal_workflow
.
getInfoFor
(
instance
,
'comment'
,
wf_id
=
'edit_workflow'
)
if
latest_comment
!=
'Allocation failed: no free Computer Partition'
:
if
latest_comment
not
in
(
'Allocation failed: no free Computer Partition'
,
'Allocation failed: Allocation disallowed'
)
:
# No nothing if allocation alarm didn't run on it
return
...
...
master/bt5/slapos_cloud/TestTemplateItem/portal_components/test.erp5.testSlapOSCloudAlarm.py
View file @
b81c9725
...
...
@@ -829,7 +829,7 @@ portal_workflow.doActionFor(context, action='edit_action', comment='Visited by S
self
.
computer
.
edit
(
**
{
base_category
:
computer_category
})
self
.
assertEquals
(
self
.
computer
.
getAllocationScope
(),
"open/public"
)
self
.
assertEquals
(
self
.
computer
.
getCapacityScope
(),
"open"
)
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
...
...
@@ -1763,6 +1763,24 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
hosting_subscription
=
instance
.
getSpecialiseValue
()
self
.
assertEqual
(
'start_requested'
,
hosting_subscription
.
getSlapState
())
def
test_tryToGarbageCollect_recent_allocation_try_found_allocation_disallowed
(
self
):
instance
=
self
.
createInstance
()
self
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
({
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
''
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
2
}),
'action'
:
'edit'
})
instance
.
Instance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'start_requested'
,
instance
.
getSlapState
())
hosting_subscription
=
instance
.
getSpecialiseValue
()
self
.
assertEqual
(
'start_requested'
,
hosting_subscription
.
getSlapState
())
def
test_tryToGarbageCollect_complex_tree
(
self
):
instance
=
self
.
createInstance
()
hosting_subscription
=
instance
.
getSpecialiseValue
()
...
...
@@ -1791,6 +1809,34 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
sub_instance
.
Instance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'start_requested'
,
hosting_subscription
.
getSlapState
())
def
test_tryToGarbageCollect_complex_tree_allocation_disallowed
(
self
):
instance
=
self
.
createInstance
()
hosting_subscription
=
instance
.
getSpecialiseValue
()
request_kw
=
dict
(
software_release
=
\
self
.
generateNewSoftwareReleaseUrl
(),
software_type
=
self
.
generateNewSoftwareType
(),
instance_xml
=
self
.
generateSafeXml
(),
sla_xml
=
self
.
generateSafeXml
(),
shared
=
False
,
software_title
=
"another %s"
%
hosting_subscription
.
getTitle
(),
state
=
'started'
)
instance
.
requestInstance
(
**
request_kw
)
sub_instance
=
instance
.
getPredecessorValue
()
self
.
tic
()
sub_instance
.
workflow_history
[
'edit_workflow'
].
append
({
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
''
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
4
}),
'action'
:
'edit'
})
sub_instance
.
Instance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'start_requested'
,
hosting_subscription
.
getSlapState
())
def
test_tryToGarbageCollect_old_allocation_try_found
(
self
):
instance
=
self
.
createInstance
()
hosting_subscription
=
instance
.
getSpecialiseValue
()
...
...
@@ -1808,6 +1854,24 @@ class TestSlapOSGarbageCollectNonAllocatedRootTreeAlarm(SlapOSTestCaseMixin):
self
.
assertEqual
(
'destroy_requested'
,
hosting_subscription
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
hosting_subscription
.
getValidationState
())
def
test_tryToGarbageCollect_old_allocation_try_found_allocation_disallowed
(
self
):
instance
=
self
.
createInstance
()
hosting_subscription
=
instance
.
getSpecialiseValue
()
self
.
tic
()
instance
.
workflow_history
[
'edit_workflow'
].
append
({
'comment'
:
'Allocation failed: Allocation disallowed'
,
'error_message'
:
''
,
'actor'
:
'ERP5TypeTestCase'
,
'slap_state'
:
''
,
'time'
:
addToDate
(
DateTime
(),
to_add
=
{
'day'
:
-
8
}),
'action'
:
'edit'
})
instance
.
Instance_tryToGarbageCollectNonAllocatedRootTree
()
self
.
assertEqual
(
'destroy_requested'
,
hosting_subscription
.
getSlapState
())
self
.
assertEqual
(
'archived'
,
hosting_subscription
.
getValidationState
())
def
_simulateInstance_tryToGarbageCollectNonAllocatedRootTree
(
self
):
script_name
=
'Instance_tryToGarbageCollectNonAllocatedRootTree'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
...
...
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