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
c78fce70
Commit
c78fce70
authored
Jan 20, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: upgrade not allocated or allocated on remote slave instances
parent
c864efa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
149 additions
and
15 deletions
+149
-15
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
...al_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
+9
-4
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
...ents/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
+140
-11
No files found.
master/bt5/slapos_pdm/SkinTemplateItem/portal_skins/slapos_pdm/InstanceTree_createUpgradeDecision.py
View file @
c78fce70
...
@@ -42,14 +42,15 @@ root_instance_list = [
...
@@ -42,14 +42,15 @@ root_instance_list = [
if
q
.
getSlapState
()
!=
'destroy_requested'
]
if
q
.
getSlapState
()
!=
'destroy_requested'
]
if
len
(
root_instance_list
)
!=
0
:
if
len
(
root_instance_list
)
!=
0
:
root_instance
=
root_instance_list
[
0
]
root_instance
=
root_instance_list
[
0
]
if
root_instance
.
getPortalType
()
==
'Slave Instance'
:
# XXX do not upgrade Slave Instance for now
# should check Instance Node or allocation on same tree
return
partition
=
root_instance
.
getAggregateValue
()
partition
=
root_instance
.
getAggregateValue
()
if
partition
is
not
None
:
if
partition
is
not
None
:
compute_node
=
partition
.
getParentValue
()
compute_node
=
partition
.
getParentValue
()
if
(
root_instance
.
getPortalType
()
==
'Slave Instance'
)
and
\
(
compute_node
.
getPortalType
()
!=
'Remote Node'
):
return
person
=
context
.
getDestinationSectionValue
()
person
=
context
.
getDestinationSectionValue
()
if
person
is
None
:
if
person
is
None
:
return
return
...
@@ -65,6 +66,10 @@ allocation_cell_list = software_product.getFollowUpValue().Project_getSoftwarePr
...
@@ -65,6 +66,10 @@ allocation_cell_list = software_product.getFollowUpValue().Project_getSoftwarePr
predicate_portal_type
=
'Allocation Supply Cell'
predicate_portal_type
=
'Allocation Supply Cell'
)
)
if
(
root_instance
.
getPortalType
()
==
'Slave Instance'
)
and
\
(
compute_node
is
None
):
allocation_cell_list
=
[
x
for
x
in
allocation_cell_list
if
(
"Remote Node"
in
[
y
.
getPortalType
()
for
y
in
x
.
getParentValue
().
getParentValue
().
getAggregateValueList
()])]
# Only upgrade if there is no doubt (ie, only 1 url is allowed)
# Only upgrade if there is no doubt (ie, only 1 url is allowed)
if
len
(
allocation_cell_list
)
==
1
:
if
len
(
allocation_cell_list
)
==
1
:
if
(
allocation_cell_list
[
0
].
getSoftwareReleaseValue
().
getUrlString
()
!=
instance_tree
.
getUrlString
()):
if
(
allocation_cell_list
[
0
].
getSoftwareReleaseValue
().
getUrlString
()
!=
instance_tree
.
getUrlString
()):
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMCreateUpgradeDecisionSkins.py
View file @
c78fce70
...
@@ -37,7 +37,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -37,7 +37,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
)
)
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
):
def
bootstrapAllocableInstanceTree
(
self
,
is_allocated
=
False
,
shared
=
False
,
node
=
"compute"
):
project
=
self
.
addProject
()
project
=
self
.
addProject
()
person
=
self
.
_makePerson
(
project
)
person
=
self
.
_makePerson
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
software_product
=
self
.
_makeSoftwareProduct
(
project
)
...
@@ -45,14 +45,22 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -45,14 +45,22 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
type_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
]
type_variation
=
software_product
.
contentValues
(
portal_type
=
'Software Product Type Variation'
)[
0
]
self
.
tic
()
self
.
tic
()
person
.
requestComputeNode
(
compute_node_title
=
'test compute node'
,
if
node
==
"compute"
:
project_reference
=
project
.
getReference
())
person
.
requestComputeNode
(
compute_node_title
=
'test compute node'
,
self
.
tic
()
project_reference
=
project
.
getReference
())
compute_node
=
self
.
portal
.
portal_catalog
.
getResultValue
(
self
.
tic
()
portal_type
=
'Compute Node'
,
compute_node
=
self
.
portal
.
portal_catalog
.
getResultValue
(
reference
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_reference'
)
portal_type
=
'Compute Node'
,
)
reference
=
self
.
portal
.
REQUEST
.
get
(
'compute_node_reference'
)
assert
compute_node
is
not
None
)
assert
compute_node
is
not
None
elif
node
==
"remote"
:
compute_node
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Remote Node"
,
follow_up_value
=
project
)
else
:
raise
ValueError
(
"Unsupported node value: %s"
%
node
)
request_kw
=
dict
(
request_kw
=
dict
(
software_release
=
release_variation
.
getUrlString
(),
software_release
=
release_variation
.
getUrlString
(),
...
@@ -78,7 +86,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -78,7 +86,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
##########################################################################
##########################################################################
# Not allocated
# Not allocated
##########################################################################
##########################################################################
def
test_createUpgradeDecision_notAllocated_newRelease
(
self
):
def
test_createUpgradeDecision_notAllocated_newRelease
OnComputeNode
(
self
):
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
...
@@ -89,6 +97,17 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -89,6 +97,17 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
def
test_createUpgradeDecision_notAllocated_newReleaseOnRemoteNode
(
self
):
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
node
=
"remote"
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node 2"
,
compute_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
def
test_createUpgradeDecision_notAllocated_sameRelease
(
self
):
def
test_createUpgradeDecision_notAllocated_sameRelease
(
self
):
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
software_product
,
release_variation
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
()
...
@@ -155,6 +174,30 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -155,6 +174,30 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
upgrade_decision2
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
upgrade_decision2
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision2
.
getSimulationState
())
self
.
assertEqual
(
'started'
,
upgrade_decision2
.
getSimulationState
())
##########################################################################
# Shared not allocated
##########################################################################
def
test_createUpgradeDecision_sharedNotAllocated_newReleaseOnComputeNode
(
self
):
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
shared
=
True
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for compute node"
,
compute_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
def
test_createUpgradeDecision_sharedNotAllocated_newReleaseOnRemoteNode
(
self
):
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
shared
=
True
,
node
=
"remote"
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node"
,
compute_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
##########################################################################
##########################################################################
# Allocated on Compute Node
# Allocated on Compute Node
##########################################################################
##########################################################################
...
@@ -205,7 +248,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -205,7 +248,7 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
##########################################################################
##########################################################################
# S
lave
allocated on Compute Node
# S
hared
allocated on Compute Node
##########################################################################
##########################################################################
def
test_createUpgradeDecision_slaveAllocatedOnComputeNodeSameTree_newReleaseOnComputeNodeButNotTree
(
self
):
def
test_createUpgradeDecision_slaveAllocatedOnComputeNodeSameTree_newReleaseOnComputeNodeButNotTree
(
self
):
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
shared
=
True
)
software_product
,
_
,
type_variation
,
compute_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
shared
=
True
)
...
@@ -229,3 +272,89 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
...
@@ -229,3 +272,89 @@ class TestSlapOSPDMCreateUpgradeDecisionSkins(TestSlapOSPDMMixinSkins):
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
##########################################################################
# Allocated on Remote Node
##########################################################################
def
test_createUpgradeDecision_allocatedOnRemoteNode_newReleaseOnRemoteNode
(
self
):
software_product
,
_
,
type_variation
,
remote_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
node
=
"remote"
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node"
,
remote_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
def
test_createUpgradeDecision_allocatedOnRemoteNode_twoRelease
(
self
):
software_product
,
release_variation
,
type_variation
,
remote_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
node
=
"remote"
)
self
.
addAllocationSupply
(
"for remote node"
,
remote_node
,
software_product
,
release_variation
,
type_variation
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for compute node 2"
,
remote_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
def
test_createUpgradeDecision_allocatedOnRemoteNode_newReleaseOnAnoterRemoteNode
(
self
):
software_product
,
_
,
type_variation
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
node
=
"remote"
)
project
=
instance_tree
.
getFollowUpValue
()
remote_node2
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Remote Node"
,
follow_up_value
=
project
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node 2"
,
remote_node2
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
##########################################################################
# Shared allocated on Remote Node
##########################################################################
def
test_createUpgradeDecision_slaveAllocatedOnRemoteNode_newReleaseOnComputeNode
(
self
):
software_product
,
_
,
type_variation
,
remote_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
shared
=
True
,
node
=
"remote"
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node"
,
remote_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
upgrade_decision
=
instance_tree
.
InstanceTree_createUpgradeDecision
()
self
.
assertEqual
(
'started'
,
upgrade_decision
.
getSimulationState
())
def
test_createUpgradeDecision_slaveAllocatedOnRemoteNode_twoRelease
(
self
):
software_product
,
release_variation
,
type_variation
,
remote_node
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
shared
=
True
,
node
=
"remote"
)
self
.
addAllocationSupply
(
"for remote node"
,
remote_node
,
software_product
,
release_variation
,
type_variation
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for compute node 2"
,
remote_node
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
def
test_createUpgradeDecision_slaveAllocatedOnRemoteNode_newReleaseOnAnoterRemoteNode
(
self
):
software_product
,
_
,
type_variation
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_allocated
=
True
,
shared
=
True
,
node
=
"remote"
)
project
=
instance_tree
.
getFollowUpValue
()
remote_node2
=
self
.
portal
.
compute_node_module
.
newContent
(
portal_type
=
"Remote Node"
,
follow_up_value
=
project
)
new_release_variation
=
self
.
_makeSoftwareRelease
(
software_product
)
self
.
addAllocationSupply
(
"for remote node 2"
,
remote_node2
,
software_product
,
new_release_variation
,
type_variation
)
self
.
tic
()
self
.
assertEqual
(
None
,
instance_tree
.
InstanceTree_createUpgradeDecision
())
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