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

[2016.3] Merge forward from 2015.8 to 2016.3 #34229

Merged
merged 7 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion salt/modules/dockerng.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
SLS files, etc. to use the new functionality, rather than forcing users to
change everything immediately.

In the **Carbon** release of Salt (due in 2016), this execution module will
In the **Nitrogen** release of Salt (due in 2017), this execution module will
take the place of the default Docker execution module, and backwards-compatible
naming will be maintained for a couple releases after that to allow users time
to replace references to ``dockerng`` with ``docker``.
Expand Down
19 changes: 16 additions & 3 deletions salt/modules/saltutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
import salt.utils.process
import salt.utils.url
import salt.wheel
import salt.utils.psutil_compat as psutil

HAS_PSUTIL = True
try:
import salt.utils.psutil_compat
except ImportError:
HAS_PSUTIL = False

from salt.exceptions import (
SaltReqTimeoutError, SaltRenderError, CommandExecutionError, SaltInvocationError
Expand Down Expand Up @@ -861,12 +866,20 @@ def signal_job(jid, sig):

salt '*' saltutil.signal_job <job id> 15
'''
if HAS_PSUTIL is False:
log.warning('saltutil.signal job called, but psutil is not installed. '
'Install psutil to ensure more reliable and accurate PID '
'management.')
for data in running():
if data['jid'] == jid:
try:
for proc in psutil.Process(pid=data['pid']).children(recursive=True):
proc.send_signal(sig)
if HAS_PSUTIL:
for proc in salt.utils.psutil_compat.Process(pid=data['pid']).children(recursive=True):
proc.send_signal(sig)
os.kill(int(data['pid']), sig)
if HAS_PSUTIL is False and '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(
int(sig),
jid,
Expand Down
6 changes: 5 additions & 1 deletion salt/modules/yumpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,11 @@ def list_repo_pkgs(*args, **kwargs):
.. versionchanged:: 2014.7.0
All available versions of each package are now returned. This required
a slight modification to the structure of the return dict. The return
data shown below reflects the updated return dict structure.
data shown below reflects the updated return dict structure. Note that
packages which are version-locked using :py:mod:`pkg.hold
<salt.modules.yumpkg.hold>` will only show the currently-installed
version, as locking a package will make other versions appear
unavailable to yum/dnf.

Returns all available packages. Optionally, package names (and name globs)
can be passed and the results will be filtered to packages matching those
Expand Down
2 changes: 1 addition & 1 deletion salt/states/dockerng.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SLS files, etc. to use the new functionality, rather than forcing users to
change everything immediately.

In the **Carbon** release of Salt (due in 2016), this execution module will
In the **Nitrogen** release of Salt (due in 2017), this execution module will
take the place of the default Docker execution module, and backwards-compatible
naming will be maintained for a couple releases after that to allow users time
to replace references to ``dockerng`` with ``docker``.
Expand Down
11 changes: 11 additions & 0 deletions salt/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ def is_empty(filename):
return False


def is_hex(value):
'''
Returns True if value is a hexidecimal string, otherwise returns False
'''
try:
int(value, 16)
return True
except (TypeError, ValueError):
return False


def get_color_theme(theme):
'''
Return the color theme to use
Expand Down
15 changes: 8 additions & 7 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ def get_tree(self, tgt_env):
return None
try:
commit = self.repo.revparse_single(tgt_ref)
except (KeyError, TypeError):
except (KeyError, TypeError, ValueError):
# Not a valid commit, likely not a commit SHA
pass
else:
Expand Down Expand Up @@ -1835,9 +1835,7 @@ def get_tree(self, tgt_env):
# SHA-1 hashes.
if not self.env_is_exposed(tgt_env):
return None
try:
int(tgt_ref, 16)
except ValueError:
elif not salt.utils.is_hex(tgt_ref):
# Not hexidecimal, likely just a non-matching environment
return None

Expand Down Expand Up @@ -2537,7 +2535,8 @@ def find_file(self, path, tgt_env='base', **kwargs): # pylint: disable=W0613
'''
fnd = {'path': '',
'rel': ''}
if os.path.isabs(path) or tgt_env not in self.envs():
if os.path.isabs(path) or \
(not salt.utils.is_hex(tgt_env) and tgt_env not in self.envs()):
return fnd

dest = os.path.join(self.cache_root, 'refs', tgt_env, path)
Expand Down Expand Up @@ -2717,7 +2716,8 @@ def _file_lists(self, load, form):
return cache_match
if refresh_cache:
ret = {'files': set(), 'symlinks': {}, 'dirs': set()}
if load['saltenv'] in self.envs():
if salt.utils.is_hex(load['saltenv']) \
or load['saltenv'] in self.envs():
for repo in self.remotes:
repo_files, repo_symlinks = repo.file_list(load['saltenv'])
ret['files'].update(repo_files)
Expand Down Expand Up @@ -2763,7 +2763,8 @@ def symlink_list(self, load):
)
load['saltenv'] = load.pop('env')

if load['saltenv'] not in self.envs():
if not salt.utils.is_hex(load['saltenv']) \
and load['saltenv'] not in self.envs():
return {}
if 'prefix' in load:
prefix = load['prefix'].strip('/')
Expand Down