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
Ivan Tyagov
slapos.core
Commits
42ea5ed7
Commit
42ea5ed7
authored
Apr 27, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapproxy: Add logs for local sr root path update
parent
da6f9e88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
slapos/proxy/views.py
slapos/proxy/views.py
+6
-1
slapos/tests/test_slapproxy.py
slapos/tests/test_slapproxy.py
+30
-0
No files found.
slapos/proxy/views.py
View file @
42ea5ed7
...
@@ -205,13 +205,18 @@ def _updateLocalSoftwareReleaseRootPathIfNeeded():
...
@@ -205,13 +205,18 @@ def _updateLocalSoftwareReleaseRootPathIfNeeded():
execute_db
(
'local_software_release_root'
,
'UPDATE %s SET path=?'
,
[
new_root_path
])
execute_db
(
'local_software_release_root'
,
'UPDATE %s SET path=?'
,
[
new_root_path
])
# Rebase all URLs relative to the new root path
# Rebase all URLs relative to the new root path
if
current_root_path
!=
new_root_path
:
if
current_root_path
!=
new_root_path
:
app
.
logger
.
info
(
'Updating local software release root path: %s --> %s'
,
current_root_path
,
new_root_path
)
def
migrate_url
(
url
):
def
migrate_url
(
url
):
if
not
url
or
urlparse
(
url
).
scheme
:
if
not
url
or
urlparse
(
url
).
scheme
:
app
.
logger
.
debug
(
'Migrate URL ? N: %s is not a path'
,
url
)
return
url
return
url
rel
=
os
.
path
.
relpath
(
url
,
current_root_path
)
rel
=
os
.
path
.
relpath
(
url
,
current_root_path
)
if
rel
.
startswith
(
os
.
pardir
+
os
.
sep
):
if
rel
.
startswith
(
os
.
pardir
+
os
.
sep
):
app
.
logger
.
debug
(
'Migrate URL ? N: %s is not a subpath'
,
url
)
return
url
return
url
return
os
.
path
.
join
(
new_root_path
,
rel
)
new
=
os
.
path
.
join
(
new_root_path
,
rel
)
app
.
logger
.
debug
(
'Migrate URL ? Y: %s -> %s'
,
url
,
new
)
return
new
g
.
db
.
create_function
(
'migrate_url'
,
1
,
migrate_url
)
g
.
db
.
create_function
(
'migrate_url'
,
1
,
migrate_url
)
execute_db
(
'software'
,
'UPDATE %s SET url=migrate_url(url)'
)
execute_db
(
'software'
,
'UPDATE %s SET url=migrate_url(url)'
)
execute_db
(
'partition'
,
'UPDATE %s SET software_release=migrate_url(software_release)'
)
execute_db
(
'partition'
,
'UPDATE %s SET software_release=migrate_url(software_release)'
)
...
...
slapos/tests/test_slapproxy.py
View file @
42ea5ed7
...
@@ -2147,6 +2147,36 @@ class TestLocalSoftwareReleaseRootPathMigration(MasterMixin):
...
@@ -2147,6 +2147,36 @@ class TestLocalSoftwareReleaseRootPathMigration(MasterMixin):
def
test_request_multiple_moves
(
self
):
def
test_request_multiple_moves
(
self
):
self
.
checkMultipleMoves
(
self
.
checkRequestUrl
)
self
.
checkMultipleMoves
(
self
.
checkRequestUrl
)
def
test_move_logs
(
self
):
local_sr_root
=
os
.
path
.
join
(
self
.
_rootdir
,
'opt'
)
subpath_url
=
os
.
path
.
join
(
local_sr_root
,
'software.cfg'
)
path_not_subpath_url
=
os
.
path
.
join
(
self
.
_rootdir
,
'srv'
,
'software.cfg'
)
http_url
=
"https://sr//"
self
.
format_for_number_of_partitions
(
3
)
for
i
,
initial_url
in
enumerate
((
subpath_url
,
path_not_subpath_url
,
http_url
)):
self
.
supply
(
initial_url
)
self
.
request
(
initial_url
,
None
,
'instance%d'
%
i
,
None
)
self
.
moveProxy
()
new_local_sr_root
=
os
.
path
.
join
(
self
.
_rootdir
,
'opt'
)
new_subpath_url
=
os
.
path
.
join
(
new_local_sr_root
,
'software.cfg'
)
with
mock
.
patch
.
object
(
views
.
app
,
'logger'
)
as
logger
:
# Request something to trigger update
self
.
getFullComputerInformation
()
logger
.
info
.
assert_called_once_with
(
'Updating local software release root path: %s --> %s'
,
local_sr_root
,
new_local_sr_root
,
)
logger
.
debug
.
assert_has_calls
([
mock
.
call
(
'Migrate URL ? Y: %s -> %s'
,
subpath_url
,
new_subpath_url
),
mock
.
call
(
'Migrate URL ? N: %s is not a subpath'
,
path_not_subpath_url
),
mock
.
call
(
'Migrate URL ? N: %s is not a path'
,
http_url
)
]
*
2
,
any_order
=
True
)
class
_MigrationTestCase
(
TestInformation
,
TestRequest
,
TestSlaveRequest
,
TestMultiNodeSupport
):
class
_MigrationTestCase
(
TestInformation
,
TestRequest
,
TestSlaveRequest
,
TestMultiNodeSupport
):
"""
"""
...
...
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