mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Current state. Almost works but JID is unavailable are seemingly random times.
This commit is contained in:
parent
85475f32aa
commit
1b595b9ecd
@ -49,7 +49,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
_DFLT_LOG_DATEFMT = '%H:%M:%S'
|
||||
_DFLT_LOG_DATEFMT_LOGFILE = '%Y-%m-%d %H:%M:%S'
|
||||
_DFLT_LOG_FMT_CONSOLE = '[JID %(jid)s] [%(levelname)-8s] %(message)s'
|
||||
_DFLT_LOG_FMT_CONSOLE = '[%(levelname)-8s] %(message)s'
|
||||
_DFLT_LOG_FMT_LOGFILE = (
|
||||
'%(asctime)s,%(msecs)03d [%(name)-17s:%(lineno)-4d][%(levelname)-8s][%(process)d] %(message)s'
|
||||
)
|
||||
|
@ -48,6 +48,7 @@ from salt.log.handlers import (TemporaryLoggingHandler,
|
||||
QueueHandler)
|
||||
from salt.log.mixins import LoggingMixInMeta, NewStyleClassMixIn
|
||||
|
||||
from salt.utils.ctx import RequestContext
|
||||
|
||||
LOG_LEVELS = {
|
||||
'all': logging.NOTSET,
|
||||
@ -265,6 +266,9 @@ class SaltLoggingClass(six.with_metaclass(LoggingMixInMeta, LOGGING_LOGGER_CLASS
|
||||
if not formatter:
|
||||
continue
|
||||
|
||||
if RequestContext.current.get('jid', None):
|
||||
formatter._fmt = '[JID %(jid)s] {0}'.format(formatter._fmt)
|
||||
|
||||
if not handler.lock:
|
||||
handler.createLock()
|
||||
handler.acquire()
|
||||
@ -308,10 +312,11 @@ class SaltLoggingClass(six.with_metaclass(LoggingMixInMeta, LOGGING_LOGGER_CLASS
|
||||
if extra is None:
|
||||
extra = {}
|
||||
|
||||
from salt.utils.ctx import RequestContext
|
||||
current_jid = RequestContext.current.get('jid', None)
|
||||
|
||||
if current_jid is not None:
|
||||
from pudb.remote import set_trace
|
||||
set_trace(term_size=(150, 40))
|
||||
extra['jid'] = current_jid
|
||||
|
||||
if exc_info and exc_info_on_loglevel:
|
||||
@ -532,7 +537,7 @@ def setup_console_logger(log_level='error', log_format=None, date_format=None):
|
||||
|
||||
# Set the default console formatter config
|
||||
if not log_format:
|
||||
log_format = '[JID %(jid)s] [%(levelname)-8s] %(message)s'
|
||||
log_format = '[%(levelname)-8s] %(message)s'
|
||||
if not date_format:
|
||||
date_format = '%H:%M:%S'
|
||||
|
||||
|
@ -91,7 +91,7 @@ try:
|
||||
except ImportError:
|
||||
HAS_HALITE = False
|
||||
|
||||
from tornado.stack_context import StackContext, run_with_stack_context
|
||||
from tornado.stack_context import StackContext
|
||||
from salt.utils.ctx import RequestContext
|
||||
|
||||
|
||||
@ -1110,13 +1110,10 @@ class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess):
|
||||
if self.opts['master_stats']:
|
||||
start = time.time()
|
||||
self.stats[cmd]['runs'] += 1
|
||||
ret = self.aes_funcs.run_func(data['cmd'], data)
|
||||
|
||||
def run_func(data):
|
||||
return self.aes_funcs.run_func(data['cmd'], data)
|
||||
|
||||
#current_request = RequestContext.current
|
||||
#ret = run_with_stack_context(StackContext(RequestContext(current_request)), run_func(data))
|
||||
with StackContext(functools.partial(RequestContext, data)):
|
||||
ret = run_func(data)
|
||||
|
||||
@ -1990,7 +1987,6 @@ class ClearFuncs(object):
|
||||
# Authorized. Do the job!
|
||||
try:
|
||||
jid = salt.utils.jid.gen_jid(self.opts)
|
||||
RequestContext.current['jid'] = jid
|
||||
fun = clear_load.pop('fun')
|
||||
tag = tagify(jid, prefix='wheel')
|
||||
data = {'fun': "wheel.{0}".format(fun),
|
||||
|
@ -28,6 +28,8 @@ import msgpack
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
|
||||
|
||||
from salt.utils.ctx import RequestContext
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# load is the published job
|
||||
@ -99,6 +101,9 @@ def prep_jid(nocache=False, passed_jid=None, recurse_count=0):
|
||||
else:
|
||||
jid = passed_jid
|
||||
|
||||
log.debug('=== adding jid to RequestContext ===')
|
||||
RequestContext.current['jid'] = jid
|
||||
|
||||
jid_dir = salt.utils.jid.jid_dir(jid, _job_dir(), __opts__['hash_type'])
|
||||
|
||||
# Make sure we create the jid dir, otherwise someone else is using it,
|
||||
|
Loading…
Reference in New Issue
Block a user