Merge "Mask dependent config errors" into feature/zuulv3
This commit is contained in:
commit
8cf27f3c64
|
@ -733,6 +733,47 @@ class TestInRepoConfig(ZuulTestCase):
|
|||
self.assertIn('the only project definition permitted', A.messages[0],
|
||||
"A should have a syntax error reported")
|
||||
|
||||
def test_untrusted_depends_on_trusted(self):
|
||||
with open(os.path.join(FIXTURE_DIR,
|
||||
'config/in-repo/git/',
|
||||
'common-config/zuul.yaml')) as f:
|
||||
common_config = f.read()
|
||||
|
||||
common_config += textwrap.dedent(
|
||||
"""
|
||||
- job:
|
||||
name: project-test9
|
||||
""")
|
||||
|
||||
file_dict = {'zuul.yaml': common_config}
|
||||
A = self.fake_gerrit.addFakeChange('common-config', 'master', 'A',
|
||||
files=file_dict)
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
- job:
|
||||
name: project-test1
|
||||
- project:
|
||||
name: org/project
|
||||
check:
|
||||
jobs:
|
||||
- project-test9
|
||||
""")
|
||||
|
||||
file_dict = {'zuul.yaml': in_repo_conf}
|
||||
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'B',
|
||||
files=file_dict)
|
||||
B.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
|
||||
B.subject, A.data['id'])
|
||||
self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
self.assertEqual(B.data['status'], 'NEW')
|
||||
self.assertEqual(B.reported, 1,
|
||||
"B should report failure")
|
||||
self.assertIn('depends on a change to a config project',
|
||||
B.messages[0],
|
||||
"A should have a syntax error reported")
|
||||
|
||||
def test_duplicate_node_error(self):
|
||||
in_repo_conf = textwrap.dedent(
|
||||
"""
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import logging
|
||||
import textwrap
|
||||
|
||||
from zuul import exceptions
|
||||
from zuul import model
|
||||
|
@ -430,6 +431,7 @@ class PipelineManager(object):
|
|||
self.log.debug("Loading dynamic layout")
|
||||
(trusted_updates, untrusted_updates) = item.includesConfigUpdates()
|
||||
build_set = item.current_build_set
|
||||
trusted_layout_verified = False
|
||||
try:
|
||||
# First parse the config as it will land with the
|
||||
# full set of config and project repos. This lets us
|
||||
|
@ -443,6 +445,7 @@ class PipelineManager(object):
|
|||
include_config_projects=True,
|
||||
scheduler=self.sched,
|
||||
connections=self.sched.connections)
|
||||
trusted_layout_verified = True
|
||||
|
||||
# Then create the config a second time but without changes
|
||||
# to config repos so that we actually use this config.
|
||||
|
@ -462,9 +465,23 @@ class PipelineManager(object):
|
|||
return item.queue.pipeline.layout
|
||||
self.log.debug("Loading dynamic layout complete")
|
||||
except zuul.configloader.ConfigurationSyntaxError as e:
|
||||
self.log.info("Configuration syntax error "
|
||||
"in dynamic layout")
|
||||
item.setConfigError(str(e))
|
||||
self.log.info("Configuration syntax error in dynamic layout")
|
||||
if trusted_layout_verified:
|
||||
# The config is good if we include config-projects,
|
||||
# but is currently invalid if we omit them. Instead
|
||||
# of returning the whole error message, just leave a
|
||||
# note that the config will work once the dependent
|
||||
# changes land.
|
||||
msg = "This change depends on a change "\
|
||||
"to a config project.\n\n"
|
||||
msg += textwrap.fill(textwrap.dedent("""\
|
||||
The syntax of the configuration in this change has
|
||||
been verified to be correct once the config project
|
||||
change upon which it depends is merged, but it can not
|
||||
be used until that occurs."""))
|
||||
item.setConfigError(msg)
|
||||
else:
|
||||
item.setConfigError(str(e))
|
||||
return None
|
||||
except Exception:
|
||||
self.log.exception("Error in dynamic layout")
|
||||
|
|
Loading…
Reference in New Issue