salt icon indicating copy to clipboard operation
salt copied to clipboard

Traceback on jobs.active

Open clearclaw opened this issue 12 years ago • 11 comments

This is with 2014.1:

$ salt-run jobs.active [ERROR ] An un-handled exception was caught by salt's global exception handler: KeyError: 'tgt' Traceback (most recent call last): File "/usr/local/bin/salt-run", line 10, in salt_run() File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/pymodules/python2.7/salt/cli/init.py", line 357, in run runner.run() File "/usr/lib/pymodules/python2.7/salt/runner.py", line 219, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/pymodules/python2.7/salt/runner.py", line 126, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 178, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt' Traceback (most recent call last): File "/usr/local/bin/salt-run", line 10, in salt_run() File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/pymodules/python2.7/salt/cli/init.py", line 357, in run runner.run() File "/usr/lib/pymodules/python2.7/salt/runner.py", line 219, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/pymodules/python2.7/salt/runner.py", line 126, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 178, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt' $ echo "Yes, the traceback is repeated twice." > /dev/null $ salt --versions-report Salt: 2014.1.0 Python: 2.7.3 (default, Feb 27 2014, 19:58:35) Jinja2: 2.6 M2Crypto: 0.21.1 msgpack-python: 0.1.10 msgpack-pure: Not Installed pycrypto: 2.4.1 PyYAML: 3.10 PyZMQ: 13.0.0 ZMQ: 3.2.2

This is under an Ubuntu 12.04.

clearclaw avatar Mar 12 '14 00:03 clearclaw

Even after upgrading to 2014.1.1 (and I've verified that the code is as it should be in the associated fix), I'm seeing the same behavior on ubuntu 12.04. Traceback and --versions-report are identical to above.

JustinFarris avatar Apr 09 '14 16:04 JustinFarris

@JustinFarris This has already been fixed in develop. See 537f96fe.

cachedout avatar Apr 09 '14 16:04 cachedout

@cachedout I see that, but as I said, even with the change listed, I'm still seeing the error.

JustinFarris avatar Apr 09 '14 17:04 JustinFarris

@JustinFarris Could you please post the stacktrace that you're receiving?

cachedout avatar Apr 09 '14 17:04 cachedout

$ sudo salt-run jobs.active [ERROR ] An un-handled exception was caught by salt's global exception handler: KeyError: 'tgt' Traceback (most recent call last): File "/usr/bin/salt-run", line 10, in salt_run() File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/pymodules/python2.7/salt/cli/init.py", line 357, in run runner.run() File "/usr/lib/pymodules/python2.7/salt/runner.py", line 219, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/pymodules/python2.7/salt/runner.py", line 126, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 186, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt' Traceback (most recent call last): File "/usr/bin/salt-run", line 10, in salt_run() File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/pymodules/python2.7/salt/cli/init.py", line 357, in run runner.run() File "/usr/lib/pymodules/python2.7/salt/runner.py", line 219, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/pymodules/python2.7/salt/runner.py", line 126, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/pymodules/python2.7/salt/runners/jobs.py", line 186, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt'

$ sudo salt --versions-report Salt: 2014.1.1 Python: 2.7.3 (default, Feb 27 2014, 19:58:35) Jinja2: 2.6 M2Crypto: 0.21.1 msgpack-python: 0.1.10 msgpack-pure: Not Installed pycrypto: 2.4.1 PyYAML: 3.10 PyZMQ: 13.0.0 ZMQ: 3.2.2

$ cat /usr/lib/pymodules/python2.7/salt/runners/jobs.py #--SNIP-- def _format_job_instance(job): return {'Function': job.get('fun', 'unknown-function'), 'Arguments': list(job.get('arg', [])), 'Target': job['tgt'], 'Target-type': job.get('tgt_type', []), 'User': job.get('user', 'root')} #--SNIP--

JustinFarris avatar Apr 09 '14 18:04 JustinFarris

Hi @JustinFarris

As mentioned before, this was fixed here.

In your snippet, you have:

'Target': job['tgt'],

Per the current HEAD, that should be:

'Target': job.get('tgt', 'unknown-target'),

This fix is not yet in any of the 2014.1 releases but it should be straightforward to change that line and hopefully eliminate the traceback that you're seeing.

cachedout avatar Apr 09 '14 18:04 cachedout

Ah, I'm a dummy. I saw one change but missed another. Sorry for the whining.

JustinFarris avatar Apr 09 '14 18:04 JustinFarris

@JustinFarris No worries at all. Glad you got this resolved!

cachedout avatar Apr 09 '14 19:04 cachedout

Hi I'm on 2014.1.5 RPM EPEL and I'm getting this stacktrace when running salt-run jobs.active. The fixed is in https://github.com/saltstack/salt/commit/537f96fe#diff-5ca65b130737a573488760e87b926385R179 based on what @cachedout said, but I don't see it in the 2014.1.5 code.

[ERROR ] An un-handled exception was caught by salt's global exception handler: KeyError: 'tgt' Traceback (most recent call last): File "/usr/bin/salt-run", line 10, in salt_run() File "/usr/lib/python2.6/site-packages/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/python2.6/site-packages/salt/cli/init.py", line 362, in run runner.run() File "/usr/lib/python2.6/site-packages/salt/runner.py", line 218, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/python2.6/site-packages/salt/runner.py", line 125, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/python2.6/site-packages/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/python2.6/site-packages/salt/runners/jobs.py", line 186, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt' Traceback (most recent call last): File "/usr/bin/salt-run", line 10, in salt_run() File "/usr/lib/python2.6/site-packages/salt/scripts.py", line 95, in salt_run client.run() File "/usr/lib/python2.6/site-packages/salt/cli/init.py", line 362, in run runner.run() File "/usr/lib/python2.6/site-packages/salt/runner.py", line 218, in run self.opts['fun'], self.opts['arg'], self.opts) File "/usr/lib/python2.6/site-packages/salt/runner.py", line 125, in cmd return self.functions[fun](*args, **kwargs) File "/usr/lib/python2.6/site-packages/salt/runners/jobs.py", line 36, in active ret[job['jid']] = _format_job_instance(job) File "/usr/lib/python2.6/site-packages/salt/runners/jobs.py", line 186, in _format_job_instance 'Target': job['tgt'], KeyError: 'tgt'

From /usr/lib/python2.6/site-packages/salt/runners/jobs.py I still see 'Target': job['tgt'], did the fix get included in 2014.1.5 ?

def _format_job_instance(job): return {'Function': job.get('fun', 'unknown-function'), 'Arguments': list(job.get('arg', [])), 'Target': job['tgt'], 'Target-type': job.get('tgt_type', []), 'User': job.get('user', 'root')}

wongster80 avatar Jul 02 '14 21:07 wongster80

@wongster80 I submitted a PR to include the necessary fix in the upcoming release of 2014.1.6.

cachedout avatar Jul 02 '14 22:07 cachedout

My another machine is OK.

yyf1986 avatar Jul 17 '14 01:07 yyf1986