Remove tenant attribute from pipeline
It is no longer used at this point. Pipelines are now independent of tenants and layouts. Change-Id: Id0c82c19759b7fd8d17914066e42aea4271cdc70
This commit is contained in:
@@ -74,7 +74,7 @@ class TestJob(BaseTestCase):
|
||||
self.tpc = model.TenantProjectConfig(self.project)
|
||||
self.tpc.trusted = True
|
||||
self.tenant.addTPC(self.tpc)
|
||||
self.pipeline = model.Pipeline('gate', self.tenant)
|
||||
self.pipeline = model.Pipeline('gate')
|
||||
self.pipeline.source_context = self.context
|
||||
self.manager = mock.Mock()
|
||||
self.manager.pipeline = self.pipeline
|
||||
|
||||
@@ -2497,7 +2497,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase):
|
||||
def test_pipeline_state_new_object(self):
|
||||
# Test the initialize-on-refresh code path with no existing object
|
||||
tenant = model.Tenant('tenant')
|
||||
pipeline = model.Pipeline('gate', tenant)
|
||||
pipeline = model.Pipeline('gate')
|
||||
layout = model.Layout(tenant)
|
||||
tenant.layout = layout
|
||||
manager = mock.Mock()
|
||||
@@ -2513,7 +2513,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase):
|
||||
def test_pipeline_state_existing_object(self):
|
||||
# Test the initialize-on-refresh code path with a pre-existing object
|
||||
tenant = model.Tenant('tenant')
|
||||
pipeline = model.Pipeline('gate', tenant)
|
||||
pipeline = model.Pipeline('gate')
|
||||
layout = model.Layout(tenant)
|
||||
tenant.layout = layout
|
||||
manager = mock.Mock()
|
||||
@@ -2537,7 +2537,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase):
|
||||
def test_pipeline_change_list_new_object(self):
|
||||
# Test the initialize-on-refresh code path with no existing object
|
||||
tenant = model.Tenant('tenant')
|
||||
pipeline = model.Pipeline('gate', tenant)
|
||||
pipeline = model.Pipeline('gate')
|
||||
layout = model.Layout(tenant)
|
||||
tenant.layout = layout
|
||||
manager = mock.Mock()
|
||||
@@ -2558,7 +2558,7 @@ class TestPipelineInit(ZooKeeperBaseTestCase):
|
||||
# Test the initialize-on-refresh code path if we don't have
|
||||
# the lock. This should fail.
|
||||
tenant = model.Tenant('tenant')
|
||||
pipeline = model.Pipeline('gate', tenant)
|
||||
pipeline = model.Pipeline('gate')
|
||||
layout = model.Layout(tenant)
|
||||
tenant.layout = layout
|
||||
manager = mock.Mock()
|
||||
|
||||
@@ -1088,7 +1088,7 @@ class Client(zuul.cmd.ZuulApp):
|
||||
|
||||
with tenant_read_lock(zk_client, args.tenant, self.log):
|
||||
path = f'/zuul/tenant/{safe_tenant}/pipeline/{safe_pipeline}'
|
||||
pipeline = Pipeline(args.pipeline, tenant)
|
||||
pipeline = Pipeline(args.pipeline)
|
||||
with pipeline_lock(
|
||||
zk_client, args.tenant, args.pipeline
|
||||
) as plock:
|
||||
|
||||
@@ -1481,7 +1481,7 @@ class PipelineParser(object):
|
||||
|
||||
def fromYaml(self, conf):
|
||||
self.schema(conf)
|
||||
pipeline = model.Pipeline(conf['name'], self.pcontext.tenant)
|
||||
pipeline = model.Pipeline(conf['name'])
|
||||
pipeline.source_context = conf['_source_context']
|
||||
pipeline.start_mark = conf['_start_mark']
|
||||
pipeline.allow_other_connections = conf.get(
|
||||
|
||||
@@ -101,7 +101,7 @@ class GerritReporter(BaseReporter):
|
||||
phase1, phase2,
|
||||
zuul_event_id=item.event)
|
||||
|
||||
def getSubmitAllowNeeds(self):
|
||||
def getSubmitAllowNeeds(self, manager):
|
||||
"""Get a list of code review labels that are allowed to be
|
||||
"needed" in the submit records for a change, with respect
|
||||
to this queue. In other words, the list of review labels
|
||||
|
||||
@@ -64,11 +64,14 @@ class GithubReporter(BaseReporter):
|
||||
self._review_body = self.config.get('review-body')
|
||||
if not isinstance(self._unlabels, list):
|
||||
self._unlabels = [self._unlabels]
|
||||
self.context = "{}/{}".format(pipeline.tenant.name, pipeline.name)
|
||||
|
||||
if 'status-url' in self.config and parse_context:
|
||||
parse_context.accumulator.addError(GithubStatusUrlDeprecation)
|
||||
|
||||
def getContext(self, manager):
|
||||
return "{}/{}".format(manager.tenant.name,
|
||||
manager.pipeline.name)
|
||||
|
||||
def report(self, item, phase1=True, phase2=True):
|
||||
"""Report on an event."""
|
||||
log = get_annotated_logger(self.log, item.event)
|
||||
@@ -203,10 +206,12 @@ class GithubReporter(BaseReporter):
|
||||
log.debug(
|
||||
'Reporting change %s, params %s, '
|
||||
'context: %s, state: %s, description: %s, url: %s',
|
||||
change, self.config, self.context, state, description, url)
|
||||
change, self.config, self.getContext(item.manager),
|
||||
state, description, url)
|
||||
|
||||
self.connection.setCommitStatus(
|
||||
project, sha, state, url, description, self.context,
|
||||
project, sha, state, url, description,
|
||||
self.getContext(item.manager),
|
||||
zuul_event_id=item.event)
|
||||
|
||||
def mergePull(self, item, change):
|
||||
@@ -301,7 +306,7 @@ class GithubReporter(BaseReporter):
|
||||
|
||||
log.debug(
|
||||
"Updating check for change %s, params %s, context %s, message: %s",
|
||||
change, self.config, self.context, message
|
||||
change, self.config, self.getContext(item.manager), message
|
||||
)
|
||||
|
||||
details_url = item.formatItemUrl()
|
||||
@@ -333,7 +338,7 @@ class GithubReporter(BaseReporter):
|
||||
sha,
|
||||
status,
|
||||
completed,
|
||||
self.context,
|
||||
self.getContext(item.manager),
|
||||
details_url,
|
||||
message,
|
||||
file_comments,
|
||||
@@ -396,7 +401,7 @@ class GithubReporter(BaseReporter):
|
||||
|
||||
return merge_message
|
||||
|
||||
def getSubmitAllowNeeds(self):
|
||||
def getSubmitAllowNeeds(self, manager):
|
||||
"""Get a list of code review labels that are allowed to be
|
||||
"needed" in the submit records for a change, with respect
|
||||
to this queue. In other words, the list of review labels
|
||||
@@ -411,7 +416,7 @@ class GithubReporter(BaseReporter):
|
||||
return []
|
||||
|
||||
# we return a status so return the status we report to github
|
||||
return [self.context]
|
||||
return [self.getContext(manager)]
|
||||
|
||||
|
||||
def getSchema():
|
||||
|
||||
@@ -137,7 +137,7 @@ class GitlabReporter(BaseReporter):
|
||||
'Merge of change %s failed after 2 attempts, giving up' %
|
||||
change)
|
||||
|
||||
def getSubmitAllowNeeds(self):
|
||||
def getSubmitAllowNeeds(self, manager):
|
||||
return []
|
||||
|
||||
|
||||
|
||||
@@ -42,11 +42,14 @@ class PagureReporter(BaseReporter):
|
||||
self._commit_status = self.config.get('status', None)
|
||||
self._create_comment = self.config.get('comment', True)
|
||||
self._merge = self.config.get('merge', False)
|
||||
self.context = "{}/{}".format(pipeline.tenant.name, pipeline.name)
|
||||
|
||||
if 'status-url' in self.config and parse_context:
|
||||
parse_context.accumulator.addError(PagureStatusUrlDeprecation)
|
||||
|
||||
def getContext(self, manager):
|
||||
return "{}/{}".format(manager.tenant.name,
|
||||
manager.pipeline.name)
|
||||
|
||||
def report(self, item, phase1=True, phase2=True):
|
||||
"""Report on an event."""
|
||||
for change in item.changes:
|
||||
@@ -120,10 +123,11 @@ class PagureReporter(BaseReporter):
|
||||
'Reporting change %s, params %s, '
|
||||
'context: %s, state: %s, description: %s, url: %s' %
|
||||
(change, self.config,
|
||||
self.context, state, description, url))
|
||||
self.getContext(item.manager), state, description, url))
|
||||
|
||||
self.connection.setCommitStatus(
|
||||
project, change_number, state, url, description, self.context)
|
||||
project, change_number, state, url, description,
|
||||
self.getContext(item.manager))
|
||||
|
||||
def mergePull(self, item, change):
|
||||
project = change.project.name
|
||||
@@ -144,7 +148,7 @@ class PagureReporter(BaseReporter):
|
||||
'Merge of change %s failed after 2 attempts, giving up' %
|
||||
change)
|
||||
|
||||
def getSubmitAllowNeeds(self):
|
||||
def getSubmitAllowNeeds(self, manager):
|
||||
return []
|
||||
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@ class ZuulReporter(BaseReporter):
|
||||
if not build.job.image_build_name:
|
||||
continue
|
||||
image_name = build.job.image_build_name
|
||||
image = self.pipeline.tenant.layout.images[image_name]
|
||||
image = item.manager.tenant.layout.images[image_name]
|
||||
for artifact in get_artifacts_from_result_data(
|
||||
build.result_data,
|
||||
logger=self.log):
|
||||
if metadata := artifact.get('metadata'):
|
||||
if metadata.get('type') == 'zuul_image':
|
||||
iba = sched.createImageBuildArtifact(
|
||||
self.pipeline.tenant.name, image, build,
|
||||
item.manager.tenant.name, image, build,
|
||||
metadata, artifact['url'],
|
||||
self.image_validated)
|
||||
sched.createImageUploads(iba)
|
||||
|
||||
@@ -37,7 +37,7 @@ def construct_build_params(uuid, connections, job, item, pipeline,
|
||||
Alternatively they contain enough information to load into another build
|
||||
environment - for example, a local runner.
|
||||
"""
|
||||
tenant = pipeline.tenant
|
||||
tenant = item.manager.tenant
|
||||
change = item.getChangeForJob(job)
|
||||
project = dict(
|
||||
name=change.project.name,
|
||||
|
||||
@@ -201,7 +201,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
# this queue itself is likely to set before submitting.
|
||||
allow_needs = set()
|
||||
for action_reporter in self.pipeline.success_actions:
|
||||
allow_needs.update(action_reporter.getSubmitAllowNeeds())
|
||||
allow_needs.update(action_reporter.getSubmitAllowNeeds(self))
|
||||
return allow_needs
|
||||
|
||||
def eventMatches(self, event, change):
|
||||
@@ -1170,7 +1170,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
|
||||
def _useNodepoolFallback(self, log, job):
|
||||
labels = {n.label for n in job.nodeset.getNodes()}
|
||||
for provider in self.pipeline.tenant.layout.providers.values():
|
||||
for provider in self.tenant.layout.providers.values():
|
||||
labels -= set(provider.labels.keys())
|
||||
if not labels:
|
||||
return False
|
||||
@@ -1327,7 +1327,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
# First collect all the config errors that are not related to the
|
||||
# current item.
|
||||
parent_error_keys = list(
|
||||
self.pipeline.tenant.layout.loading_errors.error_keys)
|
||||
self.tenant.layout.loading_errors.error_keys)
|
||||
for item_ahead in item.items_ahead:
|
||||
parent_error_keys.extend(
|
||||
e.key for e in item.item_ahead.getConfigErrors())
|
||||
@@ -2413,7 +2413,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
change_queue, change_queue.window)
|
||||
|
||||
zuul_driver = self.sched.connections.drivers['zuul']
|
||||
tenant = self.pipeline.tenant
|
||||
tenant = self.tenant
|
||||
with trace.use_span(tracing.restoreSpan(item.span_info)):
|
||||
for change in item.changes:
|
||||
source = change.project.source
|
||||
@@ -2442,7 +2442,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
if item.layout_uuid:
|
||||
layout = self.getLayout(item)
|
||||
if not layout:
|
||||
layout = self.pipeline.tenant.layout
|
||||
layout = self.tenant.layout
|
||||
|
||||
try:
|
||||
for change in item.changes:
|
||||
@@ -2559,7 +2559,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
queuekey = f'{key}.queue.{queuename}'
|
||||
|
||||
# Handle per-branch queues
|
||||
layout = self.pipeline.tenant.layout
|
||||
layout = self.tenant.layout
|
||||
queue_config = layout.queues.get(item.queue.name)
|
||||
per_branch = queue_config and queue_config.per_branch
|
||||
if per_branch and item.queue.project_branches:
|
||||
@@ -2627,7 +2627,7 @@ class PipelineManager(metaclass=ABCMeta):
|
||||
if end is None:
|
||||
end = time.time()
|
||||
pipeline = self.pipeline
|
||||
tenant = pipeline.tenant
|
||||
tenant = self.tenant
|
||||
stats_key = f'zuul.tenant.{tenant.name}.pipeline.{pipeline.name}'
|
||||
if elapsed:
|
||||
dt = start
|
||||
|
||||
@@ -555,13 +555,8 @@ class Pipeline(object):
|
||||
STATE_NORMAL = 'normal'
|
||||
STATE_ERROR = 'error'
|
||||
|
||||
def __init__(self, name, tenant):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
# Note that pipelines are not portable across tenants (new
|
||||
# pipeline objects must be made when a tenant is
|
||||
# reconfigured). A pipeline requires a tenant in order to
|
||||
# reach the currently active layout for that tenant.
|
||||
self.tenant = tenant
|
||||
self.allow_other_connections = True
|
||||
self.connections = []
|
||||
self.source_context = None
|
||||
|
||||
@@ -49,11 +49,13 @@ class BaseReporter(object, metaclass=abc.ABCMeta):
|
||||
|
||||
"""
|
||||
|
||||
def getSubmitAllowNeeds(self):
|
||||
def getSubmitAllowNeeds(self, manager):
|
||||
"""Get a list of code review labels that are allowed to be
|
||||
"needed" in the submit records for a change, with respect
|
||||
to this queue. In other words, the list of review labels
|
||||
this reporter itself is likely to set before submitting.
|
||||
|
||||
:arg PipelineManager manager: The pipeline manager for the queue.
|
||||
"""
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user