Commit d551228a authored by Boxiang Sun's avatar Boxiang Sun

try to fail when there has any stopped on-watch service

parent 6f54cc79
......@@ -880,6 +880,63 @@ class Partition(object):
raise
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):
"""Delete all files and folders in a specified directory
"""
......
......@@ -1292,6 +1292,10 @@ stderr_logfile_backups=1
if not self.force_stop:
self._checkPromiseList(local_partition)
computer_partition.started()
print("******************************")
print("******************************")
print("******************************")
local_partition.checkOnWatchServiceStatus()
self._endInstallationTransaction(computer_partition)
elif computer_partition_state == COMPUTER_PARTITION_STOPPED_STATE:
try:
......@@ -1489,6 +1493,11 @@ stderr_logfile_backups=1
except slapos.slap.ResourceNotReady:
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('=' * 80)
if process_error_partition_list:
......@@ -1539,11 +1548,21 @@ stderr_logfile_backups=1
except slapos.slap.ResourceNotReady:
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:
self.logger.info('Finished computer partitions.')
for partition, exc in promise_error_partition_list:
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
if not clean_run_promise:
return SLAPGRID_PROMISE_FAIL
......
......@@ -782,6 +782,11 @@ class TestSlapgridCPWithMaster(MasterMixin, unittest.TestCase):
partition = computer.instance_list[0]
partition.requested_state = 'started'
partition.software.setBuildout(WRAPPER_CONTENT)
print("\n----------------------------------")
print("----------------------------------")
print("----------------------------------")
print("----------------------------------")
self.grid.processComputerPartitionList()
self.assertEqual(self.grid.processComputerPartitionList(), slapgrid.SLAPGRID_SUCCESS)
self.assertInstanceDirectoryListEqual(['0'])
six.assertCountEqual(self, os.listdir(partition.partition_path),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment