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
Nicolas Wavrant
slapos.core
Commits
36c66e04
Commit
36c66e04
authored
Jan 16, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: Support slave removal
/reviewed-on
nexedi/slapos.core!179
parent
27ec7d06
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
slapos/proxy/views.py
slapos/proxy/views.py
+20
-12
slapos/tests/test_slapproxy.py
slapos/tests/test_slapproxy.py
+23
-0
No files found.
slapos/proxy/views.py
View file @
36c66e04
...
@@ -758,6 +758,14 @@ def requestSlave(software_release, software_type, partition_reference, partition
...
@@ -758,6 +758,14 @@ def requestSlave(software_release, software_type, partition_reference, partition
# Add slave to partition slave_list if not present else replace information
# Add slave to partition slave_list if not present else replace information
slave_updated_or_added
=
False
slave_updated_or_added
=
False
slave_instance_list
=
partition
[
'slave_instance_list'
]
slave_instance_list
=
partition
[
'slave_instance_list'
]
if
requested_state
==
'destroyed'
:
if
slave_instance_list
:
slave_instance_list
=
loads
(
slave_instance_list
.
encode
(
'utf-8'
))
before_count
=
len
(
slave_instance_list
)
slave_instance_list
=
[
x
for
x
in
slave_instance_list
if
x
[
'slave_reference'
]
!=
slave_reference
]
if
before_count
!=
len
(
slave_instance_list
):
slave_updated_or_added
=
True
else
:
if
slave_instance_list
:
if
slave_instance_list
:
slave_instance_list
=
loads
(
slave_instance_list
.
encode
(
'utf-8'
))
slave_instance_list
=
loads
(
slave_instance_list
.
encode
(
'utf-8'
))
for
i
,
x
in
enumerate
(
slave_instance_list
):
for
i
,
x
in
enumerate
(
slave_instance_list
):
...
...
slapos/tests/test_slapproxy.py
View file @
36c66e04
...
@@ -916,6 +916,29 @@ class TestSlaveRequest(MasterMixin):
...
@@ -916,6 +916,29 @@ class TestSlaveRequest(MasterMixin):
self
.
assertEqual
(
len
(
after
.
_parameter_dict
[
'slave_instance_list'
]),
2
)
self
.
assertEqual
(
len
(
after
.
_parameter_dict
[
'slave_instance_list'
]),
2
)
self
.
assertEqual
(
before_timestamp
,
after_timestamp
,
'No-op change of the slave shall not change the timestamp'
)
self
.
assertEqual
(
before_timestamp
,
after_timestamp
,
'No-op change of the slave shall not change the timestamp'
)
def
test_slave_request_destroyed
(
self
):
self
.
format_for_number_of_partitions
(
1
)
# Provide partition
master_partition
=
self
.
request
(
'http://sr//'
,
None
,
'MyMasterInstance'
,
'slappart4'
)
def
getPartition
():
return
self
.
getFullComputerInformation
().
_computer_partition_list
[
0
]
def
getTimestamp
(
partition
):
return
float
(
partition
.
_parameter_dict
[
'timestamp'
])
self
.
request
(
'http://sr//'
,
None
,
'MyFirstSlave'
,
shared
=
True
)
self
.
request
(
'http://sr//'
,
None
,
'MySecondSlave'
,
shared
=
True
)
after
=
getPartition
()
self
.
assertEqual
(
len
(
after
.
_parameter_dict
[
'slave_instance_list'
]),
2
)
before_timestamp
=
getTimestamp
(
after
)
time
.
sleep
(.
1
)
self
.
request
(
'http://sr//'
,
None
,
'MyFirstSlave'
,
shared
=
True
,
state
=
'destroyed'
)
after
=
getPartition
()
after_timestamp
=
getTimestamp
(
after
)
self
.
assertEqual
(
len
(
after
.
_parameter_dict
[
'slave_instance_list'
]),
1
)
self
.
assertLess
(
before_timestamp
,
after_timestamp
,
'Slave destroy shall result with timestamp update'
)
self
.
assertEqual
(
after
.
_parameter_dict
[
'slave_instance_list'
][
0
][
'slave_reference'
],
'_MySecondSlave'
)
def
test_slave_request_set_parameters_are_updated
(
self
):
def
test_slave_request_set_parameters_are_updated
(
self
):
"""
"""
...
...
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