Merge "Surface mutiple configuration issues as warnings"
This commit is contained in:
commit
a6cf0e07e9
@ -790,6 +790,14 @@ class TestConfigConflict(ZuulTestCase):
|
||||
'untrusted-zuul.yaml-job'],
|
||||
jobs)
|
||||
|
||||
tenant = self.scheds.first.sched.abide.tenants.get("tenant-one")
|
||||
errors = tenant.layout.loading_errors
|
||||
self.assertEqual(len(errors), 4)
|
||||
|
||||
for error in errors:
|
||||
self.assertEqual(error.severity, model.SEVERITY_WARNING)
|
||||
self.assertEqual(error.name, 'Multiple Project Configurations')
|
||||
|
||||
|
||||
class TestUnparsedConfigCache(ZuulTestCase):
|
||||
tenant_config_file = 'config/single-tenant/main.yaml'
|
||||
|
@ -145,6 +145,18 @@ class UnknownConnection(Exception):
|
||||
super(UnknownConnection, self).__init__(message)
|
||||
|
||||
|
||||
class MultipleProjectConfigurations(Exception):
|
||||
zuul_error_name = 'Multiple Project Configurations'
|
||||
zuul_error_severity = model.SEVERITY_WARNING
|
||||
|
||||
def __init__(self, source_context):
|
||||
message = textwrap.dedent(f"""\
|
||||
Configuration in {source_context.path} ignored because project-branch
|
||||
is already configured.""")
|
||||
message = textwrap.fill(message)
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class LabelForbiddenError(Exception):
|
||||
zuul_error_name = 'Label Forbidden'
|
||||
zuul_error_severity = model.SEVERITY_ERROR
|
||||
@ -2518,8 +2530,9 @@ class TenantParser(object):
|
||||
fn_root = fn.split('/')[0]
|
||||
if (fn_root in ZUUL_CONF_ROOT):
|
||||
if (loaded and loaded != conf_root):
|
||||
self.log.warning("Multiple configuration files in %s",
|
||||
source_context)
|
||||
with project_configuration_exceptions(
|
||||
source_context, loading_errors):
|
||||
raise MultipleProjectConfigurations(source_context)
|
||||
loaded = conf_root
|
||||
# Create a new source_context so we have unique filenames.
|
||||
source_context = source_context.copy()
|
||||
|
Loading…
x
Reference in New Issue
Block a user