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