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
Eric Zheng
slapos.core
Commits
9671b4d0
Commit
9671b4d0
authored
May 11, 2021
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proxy: allow several instances with subpartitions having same reference
parent
a01eb331
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
25 deletions
+16
-25
slapos/proxy/schema.sql
slapos/proxy/schema.sql
+1
-2
slapos/proxy/views.py
slapos/proxy/views.py
+14
-21
slapos/tests/test_slapproxy/database_dump_version_current.sql
...os/tests/test_slapproxy/database_dump_version_current.sql
+1
-2
No files found.
slapos/proxy/schema.sql
View file @
9671b4d0
...
@@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
...
@@ -23,8 +23,7 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
slave_instance_list
TEXT
,
slave_instance_list
TEXT
,
software_type
VARCHAR
(
255
),
software_type
VARCHAR
(
255
),
partition_reference
VARCHAR
(
255
),
-- name of the instance
partition_reference
VARCHAR
(
255
),
-- name of the instance
requested_by
VARCHAR
(
255
),
-- only used for debugging,
requested_by
VARCHAR
(
255
),
-- slapproxy does not support proper scope
requested_state
VARCHAR
(
255
)
NOT
NULL
DEFAULT
'started'
,
requested_state
VARCHAR
(
255
)
NOT
NULL
DEFAULT
'started'
,
timestamp
REAL
,
timestamp
REAL
,
CONSTRAINT
uniq
PRIMARY
KEY
(
reference
,
computer_reference
)
CONSTRAINT
uniq
PRIMARY
KEY
(
reference
,
computer_reference
)
...
...
slapos/proxy/views.py
View file @
9671b4d0
...
@@ -462,7 +462,9 @@ def requestComputerPartition():
...
@@ -462,7 +462,9 @@ def requestComputerPartition():
requested_computer_id
=
parsed_request_dict
[
'filter_kw'
].
get
(
'computer_guid'
,
app
.
config
[
'computer_id'
])
requested_computer_id
=
parsed_request_dict
[
'filter_kw'
].
get
(
'computer_guid'
,
app
.
config
[
'computer_id'
])
matching_partition
=
getAllocatedSlaveInstance
(
slave_reference
,
requested_computer_id
)
matching_partition
=
getAllocatedSlaveInstance
(
slave_reference
,
requested_computer_id
)
else
:
else
:
matching_partition
=
getAllocatedInstance
(
parsed_request_dict
[
'partition_reference'
])
matching_partition
=
getAllocatedInstance
(
parsed_request_dict
[
'partition_reference'
],
parsed_request_dict
[
'partition_id'
])
if
matching_partition
:
if
matching_partition
:
# Then the instance is already allocated, just update it
# Then the instance is already allocated, just update it
...
@@ -644,34 +646,27 @@ def forwardRequestToExternalMaster(master_url, request_form):
...
@@ -644,34 +646,27 @@ def forwardRequestToExternalMaster(master_url, request_form):
partition
.
_software_release_document
=
request_form
[
'software_release'
]
# type: ignore
partition
.
_software_release_document
=
request_form
[
'software_release'
]
# type: ignore
return
dumps
(
partition
)
return
dumps
(
partition
)
def
getAllocatedInstance
(
partition_reference
):
def
getAllocatedInstance
(
partition_reference
,
requested_by
):
"""
"""
Look for existence of instance, if so return the
Look for existence of instance, if so return the
corresponding partition dict, else return None
corresponding partition dict, else return None
"""
"""
args
=
[]
return
execute_db
(
'partition'
,
a
=
args
.
append
'SELECT * FROM %s WHERE partition_reference is ? AND requested_by is ?'
,
table
=
'partition'
(
partition_reference
,
requested_by
or
None
),
one
=
True
)
q
=
'SELECT * FROM %s WHERE partition_reference=?'
a
(
partition_reference
)
return
execute_db
(
table
,
q
,
args
,
one
=
True
)
def
getAllocatedSlaveInstance
(
slave_reference
,
requested_computer_id
):
def
getAllocatedSlaveInstance
(
*
args
):
"""
"""
Look for existence of instance, if so return the
Look for existence of instance, if so return the
corresponding partition dict, else return None
corresponding partition dict, else return None
"""
args
=
[]
a
=
args
.
append
# XXX: Scope currently depends on instance which requests slave.
# XXX: Scope currently depends on instance which requests slave.
# Meaning that two different instances requesting the same slave will
# Meaning that two different instances requesting the same slave will
# result in two different allocated slaves.
# result in two different allocated slaves.
table
=
'slave'
"""
q
=
'SELECT * FROM %s WHERE reference=? and computer_reference=?'
return
execute_db
(
'slave'
,
a
(
slave_reference
)
'SELECT * FROM %s WHERE reference is ? AND computer_reference is ?'
,
a
(
requested_computer_id
)
args
,
one
=
True
)
# XXX: check there is only one result
return
execute_db
(
table
,
q
,
args
,
one
=
True
)
def
getRootPartition
(
reference
):
def
getRootPartition
(
reference
):
"""Climb the partitions tree up by 'requested_by' link to get the root partition."""
"""Climb the partitions tree up by 'requested_by' link to get the root partition."""
...
@@ -696,9 +691,7 @@ def requestNotSlave(software_release, software_type, partition_reference, partit
...
@@ -696,9 +691,7 @@ def requestNotSlave(software_release, software_type, partition_reference, partit
instance_xml
=
dict2xml
(
partition_parameter_kw
)
instance_xml
=
dict2xml
(
partition_parameter_kw
)
requested_computer_id
=
filter_kw
[
'computer_guid'
]
requested_computer_id
=
filter_kw
[
'computer_guid'
]
partition
=
execute_db
(
'partition'
,
partition
=
getAllocatedInstance
(
partition_reference
,
partition_id
)
'SELECT * FROM %s WHERE partition_reference=?'
,
(
partition_reference
,),
one
=
True
)
args
=
[]
args
=
[]
a
=
args
.
append
a
=
args
.
append
...
...
slapos/tests/test_slapproxy/database_dump_version_current.sql
View file @
9671b4d0
...
@@ -26,8 +26,7 @@ CREATE TABLE partition14 (
...
@@ -26,8 +26,7 @@ CREATE TABLE partition14 (
slave_instance_list
TEXT
,
slave_instance_list
TEXT
,
software_type
VARCHAR
(
255
),
software_type
VARCHAR
(
255
),
partition_reference
VARCHAR
(
255
),
-- name of the instance
partition_reference
VARCHAR
(
255
),
-- name of the instance
requested_by
VARCHAR
(
255
),
-- only used for debugging,
requested_by
VARCHAR
(
255
),
-- slapproxy does not support proper scope
requested_state
VARCHAR
(
255
)
NOT
NULL
DEFAULT
'started'
,
requested_state
VARCHAR
(
255
)
NOT
NULL
DEFAULT
'started'
,
timestamp
REAL
,
timestamp
REAL
,
CONSTRAINT
uniq
PRIMARY
KEY
(
reference
,
computer_reference
)
CONSTRAINT
uniq
PRIMARY
KEY
(
reference
,
computer_reference
)
...
...
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