Merge pull request #36297 from rallytime/merge-2016.3

[2016.3] Merge forward from 2015.8 to 2016.3
This commit is contained in:
Nicole Thomas 2016-09-14 10:07:30 -06:00 committed by GitHub
commit a8a72c985f
3 changed files with 60 additions and 32 deletions

View File

@ -1168,7 +1168,7 @@ class LocalClient(object):
data = self.returners['{0}.get_jid'.format(self.opts['master_job_cache'])](jid)
except Exception as exc:
raise SaltClientError('Could not examine master job cache. '
'Error occured in {0} returner. '
'Error occurred in {0} returner. '
'Exception details: {1}'.format(self.opts['master_job_cache'],
exc))
for minion in data:

View File

@ -468,13 +468,17 @@ class Master(SMaster):
and not isinstance(x['git'], six.string_types)
]
if non_legacy_git_pillars:
new_opts = copy.deepcopy(self.opts)
new_opts['ext_pillar'] = non_legacy_git_pillars
try:
# Init any values needed by the git ext pillar
salt.utils.gitfs.GitPillar(new_opts)
except FileserverConfigError as exc:
critical_errors.append(exc.strerror)
new_opts = copy.deepcopy(self.opts)
from salt.pillar.git_pillar \
import PER_REMOTE_OVERRIDES as overrides
for repo in non_legacy_git_pillars:
new_opts['ext_pillar'] = [repo]
try:
git_pillar = salt.utils.gitfs.GitPillar(new_opts)
git_pillar.init_remotes(repo['git'], overrides)
except FileserverConfigError as exc:
critical_errors.append(exc.strerror)
finally:
del new_opts

View File

@ -86,7 +86,7 @@ except Exception as err: # cffi VerificationError also may happen
# but cffi might be absent as well!
# Therefore just a generic Exception class.
if not isinstance(err, ImportError):
log.error('Import pygit2 failed: {0}'.format(err))
log.error('Import pygit2 failed: %s', err)
try:
import dulwich.errors
@ -317,8 +317,8 @@ class GitProvider(object):
if os.path.isdir(root_dir):
return root_dir
log.error(
'Root path \'{0}\' not present in {1} remote \'{2}\', '
'skipping.'.format(self.root, self.role, self.id)
'Root path \'%s\' not present in %s remote \'%s\', '
'skipping.', self.root, self.role, self.id
)
return None
@ -470,7 +470,7 @@ class GitProvider(object):
self._get_lock_file(lock_type),
exc
)
log.error(msg)
log.error(msg, exc_info_on_loglevel=logging.DEBUG)
raise GitLockError(exc.errno, msg)
msg = 'Set {0} lock for {1} remote \'{2}\''.format(
lock_type,
@ -1005,7 +1005,8 @@ class Pygit2(GitProvider):
except KeyError:
log.error(
'pygit2 was unable to get SHA for %s in %s remote '
'\'%s\'', local_ref, self.role, self.id
'\'%s\'', local_ref, self.role, self.id,
exc_info_on_loglevel=logging.DEBUG
)
return None
@ -1083,7 +1084,8 @@ class Pygit2(GitProvider):
log.error(
'Unable to resolve %s from %s remote \'%s\' '
'to either an annotated or non-annotated tag',
tag_ref, self.role, self.id
tag_ref, self.role, self.id,
exc_info_on_loglevel=logging.DEBUG
)
return None
@ -1301,18 +1303,20 @@ class Pygit2(GitProvider):
'Unable to fetch SSH-based {0} remote \'{1}\'. '
'You may need to add ssh:// to the repo string or '
'libgit2 must be compiled with libssh2 to support '
'SSH authentication.'.format(self.role, self.id)
'SSH authentication.'.format(self.role, self.id),
exc_info_on_loglevel=logging.DEBUG
)
elif 'authentication required but no callback set' in exc_str:
log.error(
'{0} remote \'{1}\' requires authentication, but no '
'authentication configured'.format(self.role, self.id)
'%s remote \'%s\' requires authentication, but no '
'authentication configured', self.role, self.id,
exc_info_on_loglevel=logging.DEBUG
)
else:
log.error(
'Error occured fetching {0} remote \'{1}\': {2}'.format(
self.role, self.id, exc
)
'Error occurred fetching %s remote \'%s\': %s',
self.role, self.id, exc,
exc_info_on_loglevel=logging.DEBUG
)
return False
try:
@ -1471,12 +1475,23 @@ class Pygit2(GitProvider):
Helper function to log errors about missing auth parameters
'''
log.critical(
'Incomplete authentication information for {0} remote '
'\'{1}\'. Missing parameters: {2}'.format(
self.role,
self.id,
', '.join(missing)
)
'Incomplete authentication information for %s remote '
'\'%s\'. Missing parameters: %s',
self.role, self.id, ', '.join(missing)
)
failhard(self.role)
def _key_does_not_exist(key_type, path):
'''
Helper function to log errors about missing key file
'''
log.critical(
'SSH %s (%s) for %s remote \'%s\' could not be found, path '
'may be incorrect. Note that it may be necessary to clear '
'git_pillar locks to proceed once this is resolved and the '
'master has been started back up. A warning will be logged '
'if this is the case, with instructions.',
key_type, path, self.role, self.id
)
failhard(self.role)
@ -1507,6 +1522,15 @@ class Pygit2(GitProvider):
if all(bool(getattr(self, x, None)) for x in required_params):
keypair_params = [getattr(self, x, None) for x in
('user', 'pubkey', 'privkey', 'passphrase')]
# Check pubkey and privkey to make sure file exists
for idx, key_type in ((1, 'pubkey'), (2, 'privkey')):
key_path = keypair_params[idx]
if key_path is not None:
try:
if not os.path.isfile(key_path):
_key_does_not_exist(key_type, key_path)
except TypeError:
_key_does_not_exist(key_type, key_path)
self.credentials = pygit2.Keypair(*keypair_params)
return True
else:
@ -1639,19 +1663,18 @@ class Dulwich(GitProvider): # pylint: disable=abstract-method
refs_post = client.fetch(path, self.repo)
except dulwich.errors.NotGitRepository:
log.error(
'Dulwich does not recognize {0} as a valid remote '
'Dulwich does not recognize %s as a valid remote '
'remote URL. Perhaps it is missing \'.git\' at the '
'end.'.format(self.id)
'end.', self.id, exc_info_on_loglevel=logging.DEBUG
)
return False
except KeyError:
log.error(
'Local repository cachedir \'{0}\' (corresponding '
'remote: \'{1}\') has been corrupted. Salt will now '
'Local repository cachedir \'%s\' (corresponding '
'remote: \'%s\') has been corrupted. Salt will now '
'attempt to remove the local checkout to allow it to '
'be re-initialized in the next fileserver cache '
'update.'
.format(self.cachedir, self.id)
'update.', self.cachedir, self.id
)
try:
salt.utils.rm_rf(self.cachedir)
@ -2486,7 +2509,8 @@ class GitBase(object):
exc.errno,
repo.role,
repo.id,
exc
exc,
exc_info_on_loglevel=logging.DEBUG
)
break
else: