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
Boxiang Sun
slapos.core
Commits
d551228a
Commit
d551228a
authored
Mar 02, 2023
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to fail when there has any stopped on-watch service
parent
6f54cc79
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+57
-0
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+19
-0
slapos/tests/test_slapgrid.py
slapos/tests/test_slapgrid.py
+5
-0
No files found.
slapos/grid/SlapObject.py
View file @
d551228a
...
@@ -880,6 +880,63 @@ class Partition(object):
...
@@ -880,6 +880,63 @@ class Partition(object):
raise
raise
return
False
return
False
def
checkOnWatchServiceStatus
(
self
):
"""
Check all on-watch service status,
if any of them is not RUNNING, raise Exception and stop
"""
print
(
"=============Service Debug=========="
)
print
(
"===================================="
)
print
(
"===================================="
)
print
(
"===================================="
)
service_list
=
[]
if
os
.
path
.
exists
(
self
.
service_path
):
if
os
.
path
.
isdir
(
self
.
service_path
):
service_list
=
sorted
(
os
.
listdir
(
self
.
service_path
))
"""Asks supervisord to check if one of the processes are in the state_list."""
service_list
=
[]
print
(
os
.
listdir
(
self
.
service_path
))
state_list
=
[
'RUNNING'
,]
try
:
output
=
subprocess
.
check_output
([
'slapos'
,
'node'
,
'status'
])
except
Exception
as
e
:
output
=
str
(
e
.
output
)
content
=
output
.
split
(
'
\
\
n'
)
for
line
in
content
:
# print(line)
tokens
=
line
.
split
(
' '
)
# print(service_name)
if
'on-watch'
in
tokens
[
0
]:
service_name
=
tokens
[
0
].
split
(
':'
)[
1
]
# print(service_name)
service_list
.
append
(
service_name
)
bad_service_list
=
[]
print
(
service_list
)
for
process
in
service_list
:
with
self
.
getSupervisorRPC
()
as
supervisor
:
print
(
"Fuck!!!"
)
# info = supervisor.getProcessInfo(process_name)
print
(
info
)
if
info
[
'statename'
]
in
state_list
:
continue
# try:
# with self.getSupervisorRPC() as supervisor:
# print("Fuck!!!")
# info = supervisor.getProcessInfo(process_name)
# print(info)
# if info['statename'] in state_list:
# continue
# except xmlrpclib.Fault as exc:
# print(exc)
# if exc.faultString.startswith('BAD_NAME:'):
# self.logger.debug("BAD process name: %r" % process_name)
# print("Service name is incorrect: %r" % process_name)
# continue
# else:
# print("Service %r is not running." % process_name)
# else:
# print("All on-watch services are running.")
def
cleanupFolder
(
self
,
folder_path
):
def
cleanupFolder
(
self
,
folder_path
):
"""Delete all files and folders in a specified directory
"""Delete all files and folders in a specified directory
"""
"""
...
...
slapos/grid/slapgrid.py
View file @
d551228a
...
@@ -1292,6 +1292,10 @@ stderr_logfile_backups=1
...
@@ -1292,6 +1292,10 @@ stderr_logfile_backups=1
if
not
self
.
force_stop
:
if
not
self
.
force_stop
:
self
.
_checkPromiseList
(
local_partition
)
self
.
_checkPromiseList
(
local_partition
)
computer_partition
.
started
()
computer_partition
.
started
()
print
(
"******************************"
)
print
(
"******************************"
)
print
(
"******************************"
)
local_partition
.
checkOnWatchServiceStatus
()
self
.
_endInstallationTransaction
(
computer_partition
)
self
.
_endInstallationTransaction
(
computer_partition
)
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
elif
computer_partition_state
==
COMPUTER_PARTITION_STOPPED_STATE
:
try
:
try
:
...
@@ -1489,6 +1493,11 @@ stderr_logfile_backups=1
...
@@ -1489,6 +1493,11 @@ stderr_logfile_backups=1
except
slapos
.
slap
.
ResourceNotReady
:
except
slapos
.
slap
.
ResourceNotReady
:
return
'(not ready)'
return
'(not ready)'
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'I want generate an output here!!!'
)
self
.
logger
.
info
(
'Finished computer partitions.'
)
self
.
logger
.
info
(
'Finished computer partitions.'
)
self
.
logger
.
info
(
'='
*
80
)
self
.
logger
.
info
(
'='
*
80
)
if
process_error_partition_list
:
if
process_error_partition_list
:
...
@@ -1539,11 +1548,21 @@ stderr_logfile_backups=1
...
@@ -1539,11 +1548,21 @@ stderr_logfile_backups=1
except
slapos
.
slap
.
ResourceNotReady
:
except
slapos
.
slap
.
ResourceNotReady
:
return
'(not ready)'
return
'(not ready)'
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'---------------------------------'
)
self
.
logger
.
info
(
'I want generate an output here!!!'
)
if
promise_error_partition_list
:
if
promise_error_partition_list
:
self
.
logger
.
info
(
'Finished computer partitions.'
)
self
.
logger
.
info
(
'Finished computer partitions.'
)
for
partition
,
exc
in
promise_error_partition_list
:
for
partition
,
exc
in
promise_error_partition_list
:
self
.
logger
.
info
(
' %s[%s]: %s'
,
partition
.
getId
(),
getPartitionType
(
partition
),
exc
)
self
.
logger
.
info
(
' %s[%s]: %s'
,
partition
.
getId
(),
getPartitionType
(
partition
),
exc
)
self
.
logger
.
info
(
'================================='
)
self
.
logger
.
info
(
'================================='
)
self
.
logger
.
info
(
'================================='
)
self
.
logger
.
info
(
'I want generate an output here!!!'
)
# Return success value
# Return success value
if
not
clean_run_promise
:
if
not
clean_run_promise
:
return
SLAPGRID_PROMISE_FAIL
return
SLAPGRID_PROMISE_FAIL
...
...
slapos/tests/test_slapgrid.py
View file @
d551228a
...
@@ -782,6 +782,11 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
...
@@ -782,6 +782,11 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
partition
=
computer
.
instance_list
[
0
]
partition
=
computer
.
instance_list
[
0
]
partition
.
requested_state
=
'started'
partition
.
requested_state
=
'started'
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
partition
.
software
.
setBuildout
(
WRAPPER_CONTENT
)
print
(
"
\
n
----------------------------------"
)
print
(
"----------------------------------"
)
print
(
"----------------------------------"
)
print
(
"----------------------------------"
)
self
.
grid
.
processComputerPartitionList
()
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertEqual
(
self
.
grid
.
processComputerPartitionList
(),
slapgrid
.
SLAPGRID_SUCCESS
)
self
.
assertInstanceDirectoryListEqual
([
'0'
])
self
.
assertInstanceDirectoryListEqual
([
'0'
])
six
.
assertCountEqual
(
self
,
os
.
listdir
(
partition
.
partition_path
),
six
.
assertCountEqual
(
self
,
os
.
listdir
(
partition
.
partition_path
),
...
...
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