Merge "Surface mutiple configuration issues as warnings"

This commit is contained in:
Zuul 2023-09-27 09:13:05 +00:00 committed by Gerrit Code Review
commit a6cf0e07e9
2 changed files with 23 additions and 2 deletions

View File

@ -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'

View File

@ -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()