Merge remote-tracking branch 'upstream/2014.7' into merge-forward-2015.2

This commit is contained in:
Colton Myers 2015-02-09 15:37:25 -07:00
commit eba17606b4
4 changed files with 271 additions and 234 deletions

View File

@ -15,7 +15,8 @@ Version 2014.7.2 is a bugfix release for :doc:`2014.7.0
to lowercase their npm package names for them. The :py:mod:`npm module
<salt.modules.npm>` was never affected by mandatory lowercasing.
(:issue:`20329`)
- Deprecate the `activate` parameter for pip.install for both the
- Deprecate the ``activate`` parameter for pip.install for both the
:py:mod:`module <salt.modules.pip>` and the :py:mod:`state <salt.state.pip>`.
If `bin_env` is given and points to a virtualenv, there is no need to
If ``bin_env`` is given and points to a virtualenv, there is no need to
activate that virtualenv in a shell for pip to install to the virtualenv.
- Fix a file-locking bug in gitfs (:issue:`18839`)

View File

@ -44,7 +44,9 @@ from __future__ import absolute_import
# Import python libs
import copy
import contextlib
import distutils.version # pylint: disable=E0611
import fcntl
import glob
import hashlib
import logging
@ -890,6 +892,7 @@ def purge_cache():
remove_dirs = []
for repo in init():
try:
with _aquire_update_lock_for_repo(repo):
remove_dirs.remove(repo['hash'])
except ValueError:
pass
@ -902,6 +905,37 @@ def purge_cache():
return False
@contextlib.contextmanager
def _aquire_update_lock_for_repo(repo):
provider = _get_provider()
if provider == 'gitpython':
working_dir = repo['repo'].working_dir
elif provider == 'pygit2':
working_dir = repo['repo'].workdir
elif provider == 'dulwich':
working_dir = repo['repo'].path
with wait_for_write_lock(os.path.join(working_dir, 'update.lk')):
yield
@contextlib.contextmanager
def wait_for_write_lock(filename):
fhandle = open(filename, 'w')
if salt.utils.is_fcntl_available(check_sunos=True):
fcntl.flock(fhandle.fileno(), fcntl.LOCK_EX)
try:
yield
finally:
if salt.utils.is_fcntl_available(check_sunos=True):
fcntl.flock(fhandle.fileno(), fcntl.LOCK_UN)
fhandle.close()
os.remove(filename)
def update():
'''
Execute a git fetch on all of the repos
@ -923,9 +957,8 @@ def update():
# origin is just a url here, there is no origin object
origin = repo['url']
working_dir = repo['repo'].path
lk_fn = os.path.join(working_dir, 'update.lk')
with salt.utils.fopen(lk_fn, 'w+') as fp_:
fp_.write(str(pid))
with _aquire_update_lock_for_repo(repo):
try:
log.debug('Fetching from {0}'.format(repo['url']))
if provider == 'gitpython':
@ -1011,10 +1044,6 @@ def update():
.format(exc, repo['url']),
exc_info_on_loglevel=logging.DEBUG
)
try:
os.remove(lk_fn)
except (IOError, OSError):
pass
env_cache = os.path.join(__opts__['cachedir'], 'gitfs/envs.p')
if data.get('changed', False) is True or not os.path.isfile(env_cache):
@ -1175,6 +1204,9 @@ def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
'{0}.lk'.format(path))
destdir = os.path.dirname(dest)
hashdir = os.path.dirname(blobshadest)
for repo in init():
with _aquire_update_lock_for_repo(repo):
if not os.path.isdir(destdir):
try:
os.makedirs(destdir)
@ -1190,7 +1222,6 @@ def find_file(path, tgt_env='base', **kwargs): # pylint: disable=W0613
os.remove(hashdir)
os.makedirs(hashdir)
for repo in init():
if repo['mountpoint'] \
and not path.startswith(repo['mountpoint'] + os.path.sep):
continue

View File

@ -65,7 +65,12 @@ def _get_proc_name(proc):
It's backward compatible with < 2.0 versions of psutil.
'''
return proc.name() if PSUTIL2 else proc.name
ret = []
try:
ret = proc.name() if PSUTIL2 else proc.name
except (psutil.NoSuchProcess, psutil.AccessDenied):
pass
return ret
def _get_proc_status(proc):

View File

@ -44,7 +44,7 @@ def parse_input(args, condition=True):
_args = []
_kwargs = {}
for arg in args:
if isinstance(arg, string_types) and r'\n' not in arg and '\n' not in arg:
if isinstance(arg, string_types):
arg_name, arg_value = parse_kwarg(arg)
if arg_name:
_kwargs[arg_name] = yamlify_arg(arg_value)