Merge pull request #11857 from cachedout/8799

Catch rendering issues.
This commit is contained in:
Thomas S Hatch 2014-04-10 12:28:03 -06:00
commit 79c08ef9b6
2 changed files with 25 additions and 14 deletions

View File

@ -304,7 +304,12 @@ class Pillar(object):
Returns the high data derived from the top file
'''
tops, errors = self.get_tops()
return self.merge_tops(tops), errors
try:
merged_tops = self.merge_tops(tops)
except TypeError as err:
merged_tops = OrderedDict()
errors.append('Error encountered while render pillar top file.')
return merged_tops, errors
def top_matches(self, top):
'''

View File

@ -1971,19 +1971,22 @@ class BaseHighState(object):
for saltenv, targets in ctop.items():
if saltenv == 'include':
continue
for tgt in targets:
if tgt not in top[saltenv]:
top[saltenv][tgt] = ctop[saltenv][tgt]
continue
matches = []
states = set()
for comp in top[saltenv][tgt]:
if isinstance(comp, dict):
matches.append(comp)
if isinstance(comp, string_types):
states.add(comp)
top[saltenv][tgt] = matches
top[saltenv][tgt].extend(list(states))
try:
for tgt in targets:
if tgt not in top[saltenv]:
top[saltenv][tgt] = ctop[saltenv][tgt]
continue
matches = []
states = set()
for comp in top[saltenv][tgt]:
if isinstance(comp, dict):
matches.append(comp)
if isinstance(comp, string_types):
states.add(comp)
top[saltenv][tgt] = matches
top[saltenv][tgt].extend(list(states))
except TypeError:
raise SaltRenderError('Unable to render top file. No targets found.')
return top
def verify_tops(self, tops):
@ -2499,6 +2502,9 @@ class BaseHighState(object):
err = []
try:
top = self.get_top()
except SaltRenderError as err:
ret[tag_name]['comment'] = err.error
return ret
except Exception:
trb = traceback.format_exc()
err.append(trb)