diff options
author | Simon Westphahl <simon.westphahl@bmw.de> | 2023-02-02 10:44:38 +0100 |
---|---|---|
committer | Simon Westphahl <simon.westphahl@bmw.de> | 2023-02-08 07:48:08 +0100 |
commit | 8b96558880687d4d7e0c22e452bec7b1790749dd (patch) | |
tree | d3ca1c127139eb6591de66ffccf16b8c773bbb0e | |
parent | a5c1d3a3b8272329a3e436c979612f937933ee15 (diff) | |
download | zuul-8b96558880687d4d7e0c22e452bec7b1790749dd.tar.gz |
Replace use of ProjectContext with SourceContext
It seems we never added serialization for ProjectContext objects. This
issue showed up after I3ed9a98dfc1ed63ac11025eb792c61c9a6414384 since we
use the ProjectContext for reporting errors related to the merge mode.
Since the ProjectContext and SourceContext are almost identical we can
use a SourceContext object with irrelevant fields set to None in places
where we currently use the ProjectContext.
ERROR zuul.Pipeline.tenant.check: [e: ...] Error in dynamic layout
Traceback (most recent call last):
File "/opt/zuul/lib/python3.10/site-packages/zuul/manager/__init__.py", line 1136, in _loadDynamicLayout
item.setConfigErrors(relevant_errors)
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 5549, in setConfigErrors
self.current_build_set.setConfigErrors(errors)
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 4129, in setConfigErrors
el = ConfigurationErrorList.new(self._active_context,
File "/opt/zuul/lib/python3.10/site-packages/zuul/zk/zkobject.py", line 224, in new
data = obj._trySerialize(context)
File "/opt/zuul/lib/python3.10/site-packages/zuul/zk/zkobject.py", line 249, in _trySerialize
return self.serialize(context)
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 289, in serialize
"errors": [e.serialize() for e in self.errors],
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 289, in <listcomp>
"errors": [e.serialize() for e in self.errors],
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 254, in serialize
"key": self.key.serialize()
File "/opt/zuul/lib/python3.10/site-packages/zuul/model.py", line 211, in serialize
"context": self.context and self.context.serialize(),
AttributeError: 'ProjectContext' object has no attribute 'serialize'
Change-Id: I1b48abcd593685c332f3f218e2ed05cbcebfb244
-rw-r--r-- | zuul/configloader.py | 11 | ||||
-rw-r--r-- | zuul/model.py | 18 |
2 files changed, 7 insertions, 22 deletions
diff --git a/zuul/configloader.py b/zuul/configloader.py index 7f8346382..16bff1401 100644 --- a/zuul/configloader.py +++ b/zuul/configloader.py @@ -1770,8 +1770,10 @@ class TenantParser(object): for branch_future in as_completed(branch_futures.keys()): tpc = branch_futures[branch_future] - source_context = model.ProjectContext( - tpc.project.canonical_name, tpc.project.name) + trusted, _ = tenant.getProject(tpc.project.canonical_name) + source_context = model.SourceContext( + tpc.project.canonical_name, tpc.project.name, + tpc.project.connection_name, None, None, trusted) with project_configuration_exceptions(source_context, loading_errors): self._getProjectBranches(tenant, tpc, branch_cache_min_ltimes) @@ -2596,8 +2598,9 @@ class TenantParser(object): project_metadata.merge_mode = model.MERGER_MAP[mode] tpc = tenant.project_configs[project.canonical_name] if tpc.merge_modes is not None: - source_context = model.ProjectContext( - project.canonical_name, project.name) + source_context = model.SourceContext( + project.canonical_name, project.name, + project.connection_name, None, None, trusted) with project_configuration_exceptions(source_context, layout.loading_errors): if project_metadata.merge_mode not in tpc.merge_modes: diff --git a/zuul/model.py b/zuul/model.py index a2db42a7b..e6fa7ac3e 100644 --- a/zuul/model.py +++ b/zuul/model.py @@ -1811,24 +1811,6 @@ class FrozenSecret(ConfigObject): ) -class ProjectContext(ConfigObject): - - def __init__(self, project_canonical_name, project_name): - super().__init__() - self.project_canonical_name = project_canonical_name - self.project_name = project_name - self.branch = None - self.path = None - - def __str__(self): - return self.project_name - - def toDict(self): - return dict( - project=self.project_name, - ) - - class SourceContext(ConfigObject): """A reference to the branch of a project in configuration. |