mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
ZD 762 (#33942)
* Initial debugging * Replace the old child jid tracking with psutil investigation of children * Remove debugging
This commit is contained in:
parent
0281d491c6
commit
a74f1b8077
@ -816,27 +816,6 @@ def run(cmd,
|
|||||||
|
|
||||||
log_callback = _check_cb(log_callback)
|
log_callback = _check_cb(log_callback)
|
||||||
|
|
||||||
if 'pid' in ret and '__pub_jid' in kwargs:
|
|
||||||
# Stuff the child pid in the JID file
|
|
||||||
try:
|
|
||||||
proc_dir = os.path.join(__opts__['cachedir'], 'proc')
|
|
||||||
jid_file = os.path.join(proc_dir, kwargs['__pub_jid'])
|
|
||||||
if os.path.isfile(jid_file):
|
|
||||||
serial = salt.payload.Serial(__opts__)
|
|
||||||
with salt.utils.fopen(jid_file, 'rb') as fn_:
|
|
||||||
jid_dict = serial.load(fn_)
|
|
||||||
|
|
||||||
if 'child_pids' in jid_dict:
|
|
||||||
jid_dict['child_pids'].append(ret['pid'])
|
|
||||||
else:
|
|
||||||
jid_dict['child_pids'] = [ret['pid']]
|
|
||||||
# Rewrite file
|
|
||||||
with salt.utils.fopen(jid_file, 'w+b') as fn_:
|
|
||||||
fn_.write(serial.dumps(jid_dict))
|
|
||||||
except (NameError, TypeError):
|
|
||||||
# Avoids errors from msgpack not being loaded in salt-ssh
|
|
||||||
pass
|
|
||||||
|
|
||||||
lvl = _check_loglevel(output_loglevel)
|
lvl = _check_loglevel(output_loglevel)
|
||||||
if lvl is not None:
|
if lvl is not None:
|
||||||
if not ignore_retcode and ret['retcode'] != 0:
|
if not ignore_retcode and ret['retcode'] != 0:
|
||||||
|
@ -51,6 +51,8 @@ import salt.utils.event
|
|||||||
import salt.utils.url
|
import salt.utils.url
|
||||||
import salt.transport
|
import salt.transport
|
||||||
import salt.wheel
|
import salt.wheel
|
||||||
|
import salt.utils.psutil_compat as psutil
|
||||||
|
|
||||||
from salt.exceptions import (
|
from salt.exceptions import (
|
||||||
SaltReqTimeoutError, SaltRenderError, CommandExecutionError, SaltInvocationError
|
SaltReqTimeoutError, SaltRenderError, CommandExecutionError, SaltInvocationError
|
||||||
)
|
)
|
||||||
@ -856,10 +858,9 @@ def signal_job(jid, sig):
|
|||||||
for data in running():
|
for data in running():
|
||||||
if data['jid'] == jid:
|
if data['jid'] == jid:
|
||||||
try:
|
try:
|
||||||
|
for proc in psutil.Process(pid=data['pid']).children(recursive=True):
|
||||||
|
proc.send_signal(sig)
|
||||||
os.kill(int(data['pid']), sig)
|
os.kill(int(data['pid']), sig)
|
||||||
if 'child_pids' in data:
|
|
||||||
for pid in data['child_pids']:
|
|
||||||
os.kill(int(pid), sig)
|
|
||||||
return 'Signal {0} sent to job {1} at pid {2}'.format(
|
return 'Signal {0} sent to job {1} at pid {2}'.format(
|
||||||
int(sig),
|
int(sig),
|
||||||
jid,
|
jid,
|
||||||
|
Loading…
Reference in New Issue
Block a user