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
Cédric Le Ninivin
slapos.core
Commits
124b4537
Commit
124b4537
authored
Jul 15, 2022
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
f05131a8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
21 deletions
+108
-21
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+84
-10
slapos/tests/test_slapgrid.py
slapos/tests/test_slapgrid.py
+24
-11
No files found.
slapos/grid/slapgrid.py
View file @
124b4537
...
...
@@ -356,6 +356,7 @@ class Slapgrid(object):
buildout_debug
=
False
,
shared_part_list
=
''
,
force_stop
=
False
,
slapgrid_jio_uri
=
None
,
):
"""Makes easy initialisation of class parameters"""
# Parses arguments
...
...
@@ -390,10 +391,12 @@ class Slapgrid(object):
self
.
shadir_key_file
=
shadir_key_file
self
.
forbid_supervisord_automatic_launch
=
forbid_supervisord_automatic_launch
self
.
logger
=
logger
self
.
slapgrid_jio_uri
=
slapgrid_jio_uri
# Creates objects from slap module
self
.
slap
=
slapos
.
slap
.
slap
()
self
.
slap
.
initializeConnection
(
self
.
master_url
,
key_file
=
self
.
key_file
,
cert_file
=
self
.
cert_file
,
master_ca_file
=
self
.
master_ca_file
)
cert_file
=
self
.
cert_file
,
master_ca_file
=
self
.
master_ca_file
,
slapgrid_jio_uri
=
self
.
slapgrid_jio_uri
)
self
.
computer
=
self
.
slap
.
registerComputer
(
self
.
computer_id
)
# Defines all needed paths
self
.
buildout
=
buildout
...
...
@@ -556,10 +559,29 @@ stderr_logfile_backups=1
self
.
logger
.
info
(
'Processing software releases...'
)
# Boolean to know if every instance has correctly been deployed
clean_run
=
True
if
self
.
slap
.
jio_api_connector
:
software_installation_list
=
self
.
slap
.
jio_api_connector
.
allDocs
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
})
if
"result_list"
in
software_installation_list
:
software_installation_list
=
software_installation_list
[
"result_list"
]
else
:
software_installation_list
=
[]
backward_compatibility
=
False
else
:
software_installation_list
=
[]
for
software_release
in
self
.
computer
.
getSoftwareReleaseList
():
state
=
software_release
.
getState
()
software_installation_list
.
append
({
"software_release_uri"
:
software_release
.
getURI
(),
"state"
:
software_release
.
getState
(),
"compatibility_software_release"
:
software_release
,
})
backward_compatibility
=
True
for
software_release
in
software_installation_list
:
state
=
software_release
[
"state"
]
try
:
software_release_uri
=
software_release
.
getURI
()
software_release_uri
=
software_release
[
"software_release_uri"
]
url_hash
=
md5digest
(
software_release_uri
)
software_path
=
os
.
path
.
join
(
self
.
software_root
,
url_hash
)
software
=
Software
(
url
=
software_release_uri
,
...
...
@@ -601,7 +623,15 @@ stderr_logfile_backups=1
url_hash
in
self
.
software_release_filter_list
or
url_hash
in
(
md5digest
(
uri
)
for
uri
in
self
.
software_release_filter_list
)):
try
:
software_release
.
building
()
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"reported_state"
:
"building"
,
})
else
:
software_release
[
"compatibility_software_release"
].
building
()
except
NotFoundError
:
pass
software
.
install
()
...
...
@@ -618,14 +648,32 @@ stderr_logfile_backups=1
manager
.
softwareTearDown
(
software
)
# Send log before exiting
except
(
SystemExit
,
KeyboardInterrupt
):
software_release
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"error_status"
:
traceback
.
format_exc
(),
})
else
:
software_release
[
"compatibility_software_release"
].
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
raise
# Buildout failed: send log but don't print it to output (already done)
except
BuildoutFailedError
as
exc
:
clean_run
=
False
try
:
software_release
.
error
(
exc
,
logger
=
self
.
logger
)
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"error_status"
:
exc
,
})
else
:
software_release
[
"compatibility_software_release"
].
error
(
exc
,
logger
=
self
.
logger
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
Exception
:
...
...
@@ -634,17 +682,43 @@ stderr_logfile_backups=1
# For everything else: log it, send it, continue.
except
Exception
:
self
.
logger
.
exception
(
''
)
software_release
.
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"error_status"
:
traceback
.
format_exc
(),
})
else
:
software_release
[
"compatibility_software_release"
].
error
(
traceback
.
format_exc
(),
logger
=
self
.
logger
)
clean_run
=
False
else
:
if
state
==
'available'
:
try
:
software_release
.
available
()
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"reported_state"
:
"available"
,
})
else
:
software_release
[
"compatibility_software_release"
].
available
()
except
(
NotFoundError
,
ServerError
):
pass
elif
state
==
'destroyed'
:
try
:
software_release
.
destroyed
()
if
not
backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Installation"
,
"compute_node_id"
:
self
.
computer_id
,
"software_release_uri"
:
software_release_uri
,
"reported_state"
:
"destroyed"
,
})
else
:
software_release
[
"compatibility_software_release"
].
destroyed
()
except
(
NotFoundError
,
ServerError
):
self
.
logger
.
exception
(
''
)
self
.
logger
.
info
(
'Finished software releases.'
)
...
...
slapos/tests/test_slapgrid.py
View file @
124b4537
...
...
@@ -168,7 +168,9 @@ class BasicMixin(object):
develop
=
develop
,
logger
=
logging
.
getLogger
(),
shared_part_list
=
self
.
shared_parts_root
,
force_stop
=
force_stop
)
force_stop
=
force_stop
,
#slapgrid_jio_uri=self.master_url + "api/",
)
self
.
grid
.
_manager_list
=
self
.
manager_list
# monkey patch buildout bootstrap
...
...
@@ -396,6 +398,11 @@ class ComputerForTest(object):
qs
=
parse
.
parse_qs
(
url
.
query
)
else
:
qs
=
parse
.
parse_qs
(
req
.
body
)
# Catch API calls
#if (url.path.startwith("/api")):
# pass
if
(
url
.
path
==
'/getFullComputerInformation'
and
'computer_id'
in
qs
):
slap_computer
=
self
.
getComputer
(
qs
[
'computer_id'
][
0
])
...
...
@@ -786,6 +793,7 @@ exit 1
self
.
assertEqual
(
computer
.
sequence
,
[
'/getFullComputerInformation'
,
'/startedComputerPartition'
,
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/softwareInstanceError'
])
self
.
assertEqual
(
instance
.
state
,
'started'
)
...
...
@@ -837,7 +845,8 @@ chmod 755 etc/run/wrapper
'etc'
,
'software_release'
,
'worked'
,
'.slapos-retention-lock-delay'
])
self
.
assertLogContent
(
wrapper_log
,
'Signal handler called with signal 15'
)
self
.
assertEqual
(
computer
.
sequence
,
[
'/getHateoasUrl'
,
'/getFullComputerInformation'
,
[
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/stoppedComputerPartition'
])
self
.
assertEqual
(
instance
.
state
,
'stopped'
)
...
...
@@ -899,7 +908,8 @@ exit 1
'.slapos-retention-lock-delay'
,
'.slapgrid-0-error.log'
])
self
.
assertLogContent
(
wrapper_log
,
'Signal handler called with signal 15'
)
self
.
assertEqual
(
computer
.
sequence
,
[
'/getHateoasUrl'
,
'/getFullComputerInformation'
,
[
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/softwareInstanceError'
])
self
.
assertEqual
(
instance
.
state
,
'started'
)
...
...
@@ -935,7 +945,8 @@ exit 1
wrapper_log
=
os
.
path
.
join
(
instance
.
partition_path
,
'.0_wrapper.log'
)
self
.
assertLogContent
(
wrapper_log
,
'Working'
)
self
.
assertEqual
(
computer
.
sequence
,
[
'/getHateoasUrl'
,
'/getFullComputerInformation'
,
[
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/startedComputerPartition'
])
self
.
assertEqual
(
'started'
,
instance
.
state
)
...
...
@@ -1412,12 +1423,13 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
launchSlapgrid
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
computer
.
sequence
,
[
'/getHateoasUrl'
,
[
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/stoppedComputerPartition'
,
'/getHateoasUrl'
,
'/getFullComputerInformation'
,
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/stoppedComputerPartition'
,
'/getHateoasUrl'
,
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
])
def
test_partition_timestamp_no_timestamp
(
self
):
...
...
@@ -1437,10 +1449,11 @@ class TestSlapgridCPPartitionProcessing(MasterMixin, unittest.TestCase):
instance
.
timestamp
=
None
self
.
launchSlapgrid
()
self
.
assertEqual
(
computer
.
sequence
,
[
'/getHateoasUrl'
,
[
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/stoppedComputerPartition'
,
'/getHateoasUrl'
,
'/getFullComputerInformation'
,
'/getHateoasUrl'
,
'/getJIOAPIUrl'
,
'/getFullComputerInformation'
,
'/stoppedComputerPartition'
])
def
test_partition_periodicity_remove_timestamp
(
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