Commit 5515a973 authored by Vincent Pelletier's avatar Vincent Pelletier

Reuse SubprocessError exception in more error cases.

Prepares for task cleanup on failure.
parent e72a7c86
...@@ -57,9 +57,10 @@ class SlapOSControler(object): ...@@ -57,9 +57,10 @@ class SlapOSControler(object):
cpu_count = os.sysconf("SC_NPROCESSORS_ONLN") cpu_count = os.sysconf("SC_NPROCESSORS_ONLN")
os.putenv('MAKEFLAGS', '-j%s' % cpu_count) os.putenv('MAKEFLAGS', '-j%s' % cpu_count)
os.environ['PATH'] = environment['PATH'] os.environ['PATH'] = environment['PATH']
slapgrid = subprocess.Popen([config['slapgrid_software_binary'], '-v', '-c', command = [config['slapgrid_software_binary'], '-v', '-c',
#'--buildout-parameter',"'-U -N' -o", #'--buildout-parameter',"'-U -N' -o",
config['slapos_config']], config['slapos_config']]
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr, stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid) close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid) process_group_pid_set.add(slapgrid.pid)
...@@ -68,6 +69,7 @@ class SlapOSControler(object): ...@@ -68,6 +69,7 @@ class SlapOSControler(object):
stderr.seek(0) stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid) process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode, status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(), 'stdout':stdout.read(),
'stderr':stderr.read()} 'stderr':stderr.read()}
stdout.close() stdout.close()
...@@ -82,8 +84,9 @@ class SlapOSControler(object): ...@@ -82,8 +84,9 @@ class SlapOSControler(object):
slap.registerOpenOrder().request(self.software_profile, slap.registerOpenOrder().request(self.software_profile,
partition_reference='testing partition', partition_reference='testing partition',
partition_parameter_kw=config['instance_dict']) partition_parameter_kw=config['instance_dict'])
slapgrid = subprocess.Popen([config['slapgrid_partition_binary'], command = [config['slapgrid_partition_binary'],
config['slapos_config'], '-c', '-v'], config['slapos_config'], '-c', '-v']
slapgrid = subprocess.Popen(command,
stdout=stdout, stderr=stderr, stdout=stdout, stderr=stderr,
close_fds=True, preexec_fn=os.setsid) close_fds=True, preexec_fn=os.setsid)
process_group_pid_set.add(slapgrid.pid) process_group_pid_set.add(slapgrid.pid)
...@@ -92,6 +95,7 @@ class SlapOSControler(object): ...@@ -92,6 +95,7 @@ class SlapOSControler(object):
stderr.seek(0) stderr.seek(0)
process_group_pid_set.remove(slapgrid.pid) process_group_pid_set.remove(slapgrid.pid)
status_dict = {'status_code':slapgrid.returncode, status_dict = {'status_code':slapgrid.returncode,
'command': repr(command),
'stdout':stdout.read(), 'stdout':stdout.read(),
'stderr':stderr.read()} 'stderr':stderr.read()}
stdout.close() stdout.close()
......
...@@ -227,19 +227,22 @@ branch = %(branch)s ...@@ -227,19 +227,22 @@ branch = %(branch)s
stdout=stdout, stderr=stderr stdout=stdout, stderr=stderr
) )
if status_dict['status_code'] != 0: if status_dict['status_code'] != 0:
break safeRpcCall(master.reportTaskFailure,
if status_dict['status_code'] != 0: test_result_path, status_dict, config['test_node_title'])
safeRpcCall(master.reportTaskFailure, retry_software = True
test_result_path, status_dict, config['test_node_title']) raise SubprocessError(status_dict)
retry_software = True
continue
partition_path = os.path.join(config['instance_root'], partition_path = os.path.join(config['instance_root'],
config['partition_reference']) config['partition_reference'])
run_test_suite_path = os.path.join(partition_path, 'bin', run_test_suite_path = os.path.join(partition_path, 'bin',
'runTestSuite') 'runTestSuite')
if not os.path.exists(run_test_suite_path): if not os.path.exists(run_test_suite_path):
raise ValueError('No %r provided' % run_test_suite_path) raise SubprocessError({
'command': 'os.path.exists(run_test_suite_path)',
'status_code': 1,
'stdout': '',
'stderr': 'File does not exist: %r' % (run_test_suite_path, ),
})
run_test_suite_revision = revision run_test_suite_revision = revision
if isinstance(revision, tuple): if isinstance(revision, tuple):
......
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