Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevents 'OSError' exception in case certain job cache path doesn't exist #39400

Merged
merged 1 commit into from Feb 14, 2017

Conversation

meaksh
Copy link
Contributor

@meaksh meaksh commented Feb 14, 2017

What does this PR do?

This PR fixes an issue that may occur when exploring the local salt jobs cache.

If master has certain workload, or salt job cache is cleaned while i.a. jobs.list_jobs is running, then we're going to get an OSError exception due non-existing path.

salt/run/20170212133049657941/new	{
    "_stamp": "2017-02-12T11:30:50.125548", 
    "fun": "runner.jobs.list_jobs", 
    "jid": "20170212133049657941", 
    "user": "admin"
}
salt/run/20170212133049657941/ret	{
    "_stamp": "2017-02-12T11:30:51.183745", 
    "fun": "runner.jobs.list_jobs", 
    "jid": "20170212133049657941", 
    "return": "Exception occurred in runner jobs.list_jobs: Traceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/salt/client/mixins.py\", line 348, in low\n    data['return'] = self.functions[fun](*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/salt/runners/jobs.py\", line 333, in list_jobs\n    ret = mminion.returners['{0}.get_jids'.format(returner)]()\n  File \"/usr/lib/python2.7/site-packages/salt/returners/local_cache.py\", line 343, in get_jids\n    for jid, job, _, _ in _walk_through(_job_dir()):\n  File \"/usr/lib/python2.7/site-packages/salt/returners/local_cache.py\", line 69, in _walk_through\n    for final in os.listdir(t_path):\nOSError: [Errno 2] No such file or directory: '/var/cache/salt/master/jobs/32'\n", 
    "success": false, 
    "user": "admin"
}

The _walk_through loop is not checking the actual existence of the t_path before accessing it. We should ensure that such path is existing just before calling os.listdir().

Same is already done for the final job file just before open it.

Tests written?

No

/cc @moio

@cachedout cachedout merged commit 1116d32 into saltstack:2016.3 Feb 14, 2017
@cachedout
Copy link
Contributor

Very good. Thanks, @meaksh

@meaksh meaksh deleted the 2016.3-fix-local-cache-issue branch February 15, 2017 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants