Merge "Fix race in test_crd_gate_unknown" into feature/zuulv3
diff --git a/doc/source/developer/datamodel.rst b/doc/source/developer/datamodel.rst
index acb8612..c4ff4a0 100644
--- a/doc/source/developer/datamodel.rst
+++ b/doc/source/developer/datamodel.rst
@@ -8,7 +8,7 @@
Pipelines have a configured
:py:class:`~zuul.manager.PipelineManager` which controlls how
-the :py:class:`Change <zuul.model.Changeish>` objects are enqueued and
+the :py:class:`Ref <zuul.model.Ref>` objects are enqueued and
processed.
There are currently two,
@@ -35,7 +35,7 @@
.. autoclass:: zuul.model.Build
The :py:class:`~zuul.manager.base.PipelineManager` enqueues each
-:py:class:`Change <zuul.model.Changeish>` into the
+:py:class:`Ref <zuul.model.Ref>` into the
:py:class:`~zuul.model.ChangeQueue` in a :py:class:`~zuul.model.QueueItem`.
.. autoclass:: zuul.model.QueueItem
diff --git a/tests/base.py b/tests/base.py
index d8f88b7..76d604f 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -605,21 +605,6 @@
def getPullRequestClosedEvent(self):
return self._getPullRequestEvent('closed')
- def getPushEvent(self, old_sha, ref='refs/heads/master'):
- name = 'push'
- data = {
- 'ref': ref,
- 'before': old_sha,
- 'after': self.head_sha,
- 'repository': {
- 'full_name': self.project
- },
- 'sender': {
- 'login': 'ghuser'
- }
- }
- return (name, data)
-
def addComment(self, message):
self.comments.append(message)
self._updateTimeStamp()
@@ -909,7 +894,8 @@
self.pull_requests.append(pull_request)
return pull_request
- def getPushEvent(self, project, ref, old_rev=None, new_rev=None):
+ def getPushEvent(self, project, ref, old_rev=None, new_rev=None,
+ added_files=[], removed_files=[], modified_files=[]):
if not old_rev:
old_rev = '00000000000000000000000000000000'
if not new_rev:
@@ -921,7 +907,14 @@
'after': new_rev,
'repository': {
'full_name': project
- }
+ },
+ 'commits': [
+ {
+ 'added': added_files,
+ 'removed': removed_files,
+ 'modified': modified_files
+ }
+ ]
}
return (name, data)
diff --git a/tests/fixtures/layout-merge-failure.yaml b/tests/fixtures/layout-merge-failure.yaml
deleted file mode 100644
index 72bc9c9..0000000
--- a/tests/fixtures/layout-merge-failure.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-pipelines:
- - name: check
- manager: IndependentPipelineManager
- trigger:
- gerrit:
- - event: patchset-created
- success:
- gerrit:
- verified: 1
- failure:
- gerrit:
- verified: -1
-
- - name: post
- manager: IndependentPipelineManager
- trigger:
- gerrit:
- - event: ref-updated
- ref: ^(?!refs/).*$
-
- - name: gate
- manager: DependentPipelineManager
- failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
- merge-failure-message: "The merge failed! For more information..."
- trigger:
- gerrit:
- - event: comment-added
- approval:
- - approved: 1
- success:
- gerrit:
- verified: 2
- submit: true
- failure:
- gerrit:
- verified: -2
- merge-failure:
- gerrit:
- verified: -1
- smtp:
- to: you@example.com
- start:
- gerrit:
- verified: 0
- precedence: high
-
-projects:
- - name: org/project
- check:
- - project-merge:
- - project-test1
- - project-test2
- gate:
- - project-merge:
- - project-test1
- - project-test2
diff --git a/tests/fixtures/layouts/merge-failure.yaml b/tests/fixtures/layouts/merge-failure.yaml
new file mode 100644
index 0000000..228963f
--- /dev/null
+++ b/tests/fixtures/layouts/merge-failure.yaml
@@ -0,0 +1,74 @@
+- pipeline:
+ name: check
+ manager: independent
+ trigger:
+ gerrit:
+ - event: patchset-created
+ success:
+ gerrit:
+ verified: 1
+ failure:
+ gerrit:
+ verified: -1
+
+- pipeline:
+ name: post
+ manager: independent
+ trigger:
+ gerrit:
+ - event: ref-updated
+ ref: ^(?!refs/).*$
+
+- pipeline:
+ name: gate
+ manager: dependent
+ failure-message: Build failed. For information on how to proceed, see http://wiki.example.org/Test_Failures
+ merge-failure-message: "The merge failed! For more information..."
+ trigger:
+ gerrit:
+ - event: comment-added
+ approval:
+ - approved: 1
+ success:
+ gerrit:
+ verified: 2
+ submit: true
+ failure:
+ gerrit:
+ verified: -2
+ merge-failure:
+ gerrit:
+ verified: -1
+ smtp:
+ to: you@example.com
+ start:
+ gerrit:
+ verified: 0
+ precedence: high
+
+- job:
+ name: project-merge
+ hold-following-changes: true
+
+- job:
+ name: project-test1
+
+- job:
+ name: project-test2
+
+- project:
+ name: org/project
+ check:
+ jobs:
+ - project-merge
+ - project-test1:
+ dependencies: project-merge
+ - project-test2:
+ dependencies: project-merge
+ gate:
+ jobs:
+ - project-merge
+ - project-test1:
+ dependencies: project-merge
+ - project-test2:
+ dependencies: project-merge
diff --git a/tests/unit/test_executor.py b/tests/unit/test_executor.py
index 100e4ec..39b6070 100644
--- a/tests/unit/test_executor.py
+++ b/tests/unit/test_executor.py
@@ -61,6 +61,19 @@
'not have change %s' % (
project, build, number, change.subject))
+ def assertBuildStates(self, states, projects):
+ for number, build in enumerate(self.builds):
+ work = build.getWorkspaceRepos(projects)
+ state = states[number]
+
+ for project in projects:
+ self.assertRepoState(work[project], state[project],
+ project, build, number)
+
+ self.executor_server.hold_jobs_in_build = False
+ self.executor_server.release()
+ self.waitUntilSettled()
+
@simple_layout('layouts/repo-checkout-two-project.yaml')
def test_one_branch(self):
self.executor_server.hold_jobs_in_build = True
@@ -90,18 +103,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-four-project.yaml')
def test_multi_branch(self):
@@ -156,18 +158,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-six-project.yaml')
def test_project_override(self):
@@ -252,18 +243,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
def test_periodic(self):
# This test can not use simple_layout because it must start
@@ -300,18 +280,7 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
@simple_layout('layouts/repo-checkout-post.yaml')
def test_post_and_master_checkout(self):
@@ -335,15 +304,4 @@
},
]
- for number, build in enumerate(self.builds):
- self.log.debug("Build parameters: %s", build.parameters)
- work = build.getWorkspaceRepos(projects)
- state = states[number]
-
- for project in projects:
- self.assertRepoState(work[project], state[project],
- project, build, number)
-
- self.executor_server.hold_jobs_in_build = False
- self.executor_server.release()
- self.waitUntilSettled()
+ self.assertBuildStates(states, projects)
diff --git a/tests/unit/test_github_driver.py b/tests/unit/test_github_driver.py
index 6cc010e..2013ee0 100644
--- a/tests/unit/test_github_driver.py
+++ b/tests/unit/test_github_driver.py
@@ -513,3 +513,18 @@
self.assertNotIn('merge', A.labels)
self.assertNotIn('merge', B.labels)
self.assertNotIn('merge', C.labels)
+
+ @simple_layout('layouts/basic-github.yaml', driver='github')
+ def test_push_event_reconfigure(self):
+ pevent = self.fake_github.getPushEvent(project='common-config',
+ ref='refs/heads/master',
+ modified_files=['zuul.yaml'])
+
+ # record previous tenant reconfiguration time, which may not be set
+ old = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
+ time.sleep(1)
+ self.fake_github.emitEvent(pevent)
+ self.waitUntilSettled()
+ new = self.sched.tenant_last_reconfigured.get('tenant-one', 0)
+ # New timestamp should be greater than the old timestamp
+ self.assertLess(old, new)
diff --git a/tests/unit/test_push_reqs.py b/tests/unit/test_push_reqs.py
index 657d9b8..d3a1feb 100644
--- a/tests/unit/test_push_reqs.py
+++ b/tests/unit/test_push_reqs.py
@@ -28,7 +28,10 @@
# Create a github change, add a change and emit a push event
A = self.fake_github.openFakePullRequest('org/project1', 'master', 'A')
old_sha = A.head_sha
- self.fake_github.emitEvent(A.getPushEvent(old_sha))
+ pevent = self.fake_github.getPushEvent(project='org/project1',
+ ref='refs/heads/master',
+ old_rev=old_sha)
+ self.fake_github.emitEvent(pevent)
self.waitUntilSettled()
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 19bcb61..de8246c 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -29,6 +29,7 @@
import testtools
import zuul.change_matcher
+from zuul.driver.gerrit import gerritreporter
import zuul.scheduler
import zuul.rpcclient
import zuul.model
@@ -3333,7 +3334,6 @@
self.assertEqual(queue.window_floor, 1)
self.assertEqual(C.data['status'], 'MERGED')
- @skip("Disabled for early v3 development")
def test_worker_update_metadata(self):
"Test if a worker can send back metadata about itself"
self.executor_server.hold_jobs_in_build = True
@@ -3343,17 +3343,17 @@
self.fake_gerrit.addEvent(A.addApproval('approved', 1))
self.waitUntilSettled()
- self.assertEqual(len(self.executor.builds), 1)
+ self.assertEqual(len(self.executor_client.builds), 1)
self.log.debug('Current builds:')
- self.log.debug(self.executor.builds)
+ self.log.debug(self.executor_client.builds)
start = time.time()
while True:
if time.time() - start > 10:
raise Exception("Timeout waiting for gearman server to report "
+ "back to the client")
- build = list(self.executor.builds.values())[0]
+ build = list(self.executor_client.builds.values())[0]
if build.worker.name == "My Worker":
break
else:
@@ -3361,12 +3361,6 @@
self.log.debug(build)
self.assertEqual("My Worker", build.worker.name)
- self.assertEqual("localhost", build.worker.hostname)
- self.assertEqual(['127.0.0.1', '192.168.1.1'], build.worker.ips)
- self.assertEqual("zuul.example.org", build.worker.fqdn)
- self.assertEqual("FakeBuilder", build.worker.program)
- self.assertEqual("v1.1", build.worker.version)
- self.assertEqual({'something': 'else'}, build.worker.extra)
self.executor_server.hold_jobs_in_build = False
self.executor_server.release()
@@ -3410,49 +3404,45 @@
self.assertEqual(0, len(A.messages))
- @skip("Disabled for early v3 development")
+ @simple_layout('layouts/merge-failure.yaml')
def test_merge_failure_reporters(self):
"""Check that the config is set up correctly"""
- self.updateConfigLayout(
- 'tests/fixtures/layout-merge-failure.yaml')
- self.sched.reconfigure(self.config)
- self.registerJobs()
-
+ tenant = self.sched.abide.tenants.get('tenant-one')
self.assertEqual(
"Merge Failed.\n\nThis change or one of its cross-repo "
"dependencies was unable to be automatically merged with the "
"current state of its repository. Please rebase the change and "
"upload a new patchset.",
- self.sched.layout.pipelines['check'].merge_failure_message)
+ tenant.layout.pipelines['check'].merge_failure_message)
self.assertEqual(
"The merge failed! For more information...",
- self.sched.layout.pipelines['gate'].merge_failure_message)
+ tenant.layout.pipelines['gate'].merge_failure_message)
self.assertEqual(
- len(self.sched.layout.pipelines['check'].merge_failure_actions), 1)
+ len(tenant.layout.pipelines['check'].merge_failure_actions), 1)
self.assertEqual(
- len(self.sched.layout.pipelines['gate'].merge_failure_actions), 2)
+ len(tenant.layout.pipelines['gate'].merge_failure_actions), 2)
self.assertTrue(isinstance(
- self.sched.layout.pipelines['check'].merge_failure_actions[0],
- zuul.reporter.gerrit.GerritReporter))
+ tenant.layout.pipelines['check'].merge_failure_actions[0],
+ gerritreporter.GerritReporter))
self.assertTrue(
(
- isinstance(self.sched.layout.pipelines['gate'].
+ isinstance(tenant.layout.pipelines['gate'].
merge_failure_actions[0],
- zuul.reporter.smtp.SMTPReporter) and
- isinstance(self.sched.layout.pipelines['gate'].
+ zuul.driver.smtp.smtpreporter.SMTPReporter) and
+ isinstance(tenant.layout.pipelines['gate'].
merge_failure_actions[1],
- zuul.reporter.gerrit.GerritReporter)
+ gerritreporter.GerritReporter)
) or (
- isinstance(self.sched.layout.pipelines['gate'].
+ isinstance(tenant.layout.pipelines['gate'].
merge_failure_actions[0],
- zuul.reporter.gerrit.GerritReporter) and
- isinstance(self.sched.layout.pipelines['gate'].
+ gerritreporter.GerritReporter) and
+ isinstance(tenant.layout.pipelines['gate'].
merge_failure_actions[1],
- zuul.reporter.smtp.SMTPReporter)
+ zuul.driver.smtp.smtpreporter.SMTPReporter)
)
)
@@ -3563,7 +3553,7 @@
self.assertEqual(False, job['retry'])
self.assertEqual('https://server/job/project-merge/0/',
job['url'])
- self.assertEqual(7, len(job['worker']))
+ self.assertEqual(2, len(job['worker']))
self.assertEqual(False, job['canceled'])
self.assertEqual(True, job['voting'])
self.assertIsNone(job['result'])
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 18a49db..707515a 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -328,6 +328,46 @@
self.assertIn('not permitted to shadow', A.messages[0],
"A should have a syntax error reported")
+ def test_untrusted_pipeline_error(self):
+ in_repo_conf = textwrap.dedent(
+ """
+ - pipeline:
+ name: test
+ """)
+
+ file_dict = {'.zuul.yaml': in_repo_conf}
+ A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+ files=file_dict)
+ A.addApproval('code-review', 2)
+ self.fake_gerrit.addEvent(A.addApproval('approved', 1))
+ self.waitUntilSettled()
+
+ self.assertEqual(A.data['status'], 'NEW')
+ self.assertEqual(A.reported, 1,
+ "A should report failure")
+ self.assertIn('Pipelines may not be defined', A.messages[0],
+ "A should have a syntax error reported")
+
+ def test_untrusted_project_error(self):
+ in_repo_conf = textwrap.dedent(
+ """
+ - project:
+ name: org/project1
+ """)
+
+ file_dict = {'.zuul.yaml': in_repo_conf}
+ A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A',
+ files=file_dict)
+ A.addApproval('code-review', 2)
+ self.fake_gerrit.addEvent(A.addApproval('approved', 1))
+ self.waitUntilSettled()
+
+ self.assertEqual(A.data['status'], 'NEW')
+ self.assertEqual(A.reported, 1,
+ "A should report failure")
+ self.assertIn('the only project definition permitted', A.messages[0],
+ "A should have a syntax error reported")
+
class TestAnsible(AnsibleZuulTestCase):
# A temporary class to hold new tests while others are disabled
diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py
index 487096f..3f67a38 100644
--- a/zuul/cmd/client.py
+++ b/zuul/cmd/client.py
@@ -284,22 +284,6 @@
'worker.hostname': {
'title': 'Worker Hostname'
},
- 'worker.ips': {
- 'title': 'Worker IPs',
- 'transform': self._format_list
- },
- 'worker.fqdn': {
- 'title': 'Worker Domain'
- },
- 'worker.program': {
- 'title': 'Worker Program'
- },
- 'worker.version': {
- 'title': 'Worker Version'
- },
- 'worker.extra': {
- 'title': 'Worker Extra'
- },
}
diff --git a/zuul/configloader.py b/zuul/configloader.py
index 42a9b01..f78e8a4 100644
--- a/zuul/configloader.py
+++ b/zuul/configloader.py
@@ -68,6 +68,24 @@
super(ProjectNotFoundError, self).__init__(message)
+class PipelineNotPermittedError(Exception):
+ def __init__(self):
+ message = textwrap.dedent("""\
+ Pipelines may not be defined in untrusted repos,
+ they may only be defined in config repos.""")
+ message = textwrap.fill(message)
+ super(PipelineNotPermittedError, self).__init__(message)
+
+
+class ProjectNotPermittedError(Exception):
+ def __init__(self):
+ message = textwrap.dedent("""\
+ Within an untrusted project, the only project definition
+ permitted is that of the project itself.""")
+ message = textwrap.fill(message)
+ super(ProjectNotPermittedError, self).__init__(message)
+
+
def indent(s):
return '\n'.join([' ' + x for x in s.split('\n')])
@@ -586,6 +604,11 @@
configs = []
for conf in conf_list:
+ with configuration_exceptions('project', conf):
+ if not conf['_source_context'].trusted:
+ if project != conf['_source_context'].project:
+ raise ProjectNotPermittedError()
+
# Make a copy since we modify this later via pop
conf = copy.deepcopy(conf)
conf_templates = conf.pop('templates', [])
@@ -797,12 +820,12 @@
for source_name, require_config in conf.get('require', {}).items():
source = connections.getSource(source_name)
- manager.changeish_filters.extend(
+ manager.ref_filters.extend(
source.getRequireFilters(require_config))
for source_name, reject_config in conf.get('reject', {}).items():
source = connections.getSource(source_name)
- manager.changeish_filters.extend(
+ manager.ref_filters.extend(
source.getRejectFilters(reject_config))
for trigger_name, trigger_config in conf.get('trigger').items():
@@ -1059,10 +1082,11 @@
@staticmethod
def _parseUntrustedProjectLayout(data, source_context):
- # TODOv3(jeblair): this should implement some rules to protect
- # aspects of the config that should not be changed in-repo
config = model.UnparsedTenantConfig()
config.extend(safe_load_yaml(data, source_context))
+ if config.pipelines:
+ with configuration_exceptions('pipeline', config.pipelines[0]):
+ raise PipelineNotPermittedError()
return config
@staticmethod
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py
index a5e1f22..fa43e66 100644
--- a/zuul/driver/gerrit/gerritconnection.py
+++ b/zuul/driver/gerrit/gerritconnection.py
@@ -75,6 +75,14 @@
time.sleep(max((ts + self.delay) - now, 0.0))
event = GerritTriggerEvent()
event.type = data.get('type')
+ # This catches when a change is merged, as it could potentially
+ # have merged layout info which will need to be read in.
+ # Ideally this would be done with a refupdate event so as to catch
+ # directly pushed things as well as full changes being merged.
+ # But we do not yet get files changed data for pure refupdate events.
+ # TODO(jlk): handle refupdated events instead of just changes
+ if event.type == 'change-merged':
+ event.branch_updated = True
event.trigger_name = 'gerrit'
change = data.get('change')
event.project_hostname = self.connection.canonical_hostname
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py
index 6a3c09e..659d88b 100644
--- a/zuul/driver/github/githubconnection.py
+++ b/zuul/driver/github/githubconnection.py
@@ -129,10 +129,12 @@
event.trigger_name = 'github'
event.project_name = base_repo.get('full_name')
event.type = 'push'
+ event.branch_updated = True
event.ref = body.get('ref')
event.oldrev = body.get('before')
event.newrev = body.get('after')
+ event.commits = body.get('commits')
ref_parts = event.ref.split('/') # ie, ['refs', 'heads', 'master']
@@ -490,6 +492,7 @@
change.newrev = event.newrev
change.url = self.getGitwebUrl(project, sha=event.newrev)
change.source_event = event
+ change.files = self.getPushedFileNames(event)
else:
change = Ref(project)
return change
@@ -728,6 +731,13 @@
pr = self.getPull(project, number)
return pr.get('head').get('sha') == sha
+ def getPushedFileNames(self, event):
+ files = set()
+ for c in event.commits:
+ for f in c.get('added') + c.get('modified') + c.get('removed'):
+ files.add(f)
+ return list(files)
+
def _ghTimestampToDate(self, timestamp):
return time.strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ')
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 8d2d577..9514454 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -417,12 +417,13 @@
self.command_socket = commandsocket.CommandSocket(path)
ansible_dir = os.path.join(state_dir, 'ansible')
self.ansible_dir = ansible_dir
+ if os.path.exists(ansible_dir):
+ shutil.rmtree(ansible_dir)
zuul_dir = os.path.join(ansible_dir, 'zuul')
plugin_dir = os.path.join(zuul_dir, 'ansible')
- if not os.path.exists(plugin_dir):
- os.makedirs(plugin_dir)
+ os.makedirs(plugin_dir, mode=0o0755)
self.library_dir = os.path.join(plugin_dir, 'library')
self.action_dir = os.path.join(plugin_dir, 'action')
@@ -803,17 +804,6 @@
'worker_name': 'My Worker',
}
- # TODOv3:
- # 'name': self.name,
- # 'manager': self.executor_server.hostname,
- # 'worker_name': 'My Worker',
- # 'worker_hostname': 'localhost',
- # 'worker_ips': ['127.0.0.1', '192.168.1.1'],
- # 'worker_fqdn': 'zuul.example.org',
- # 'worker_program': 'FakeBuilder',
- # 'worker_version': 'v1.1',
- # 'worker_extra': {'something': 'else'}
-
self.job.sendWorkData(json.dumps(data))
self.job.sendWorkStatus(0, 100)
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 3728c73..c3958d7 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -47,7 +47,7 @@
self.sched = sched
self.pipeline = pipeline
self.event_filters = []
- self.changeish_filters = []
+ self.ref_filters = []
def __str__(self):
return "<%s %s>" % (self.__class__.__name__, self.pipeline.name)
@@ -55,7 +55,7 @@
def _postConfig(self, layout):
self.log.info("Configured Pipeline Manager %s" % self.pipeline.name)
self.log.info(" Requirements:")
- for f in self.changeish_filters:
+ for f in self.ref_filters:
self.log.info(" %s" % f)
self.log.info(" Events:")
for e in self.event_filters:
@@ -281,7 +281,7 @@
return False
if not ignore_requirements:
- for f in self.changeish_filters:
+ for f in self.ref_filters:
if f.connection_name != change.project.connection_name:
self.log.debug("Filter %s skipped for change %s due "
"to mismatched connections" % (f, change))
diff --git a/zuul/model.py b/zuul/model.py
index 6ad34ff..1bd077b 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -1108,21 +1108,11 @@
def __init__(self):
self.name = "Unknown"
self.hostname = None
- self.ips = []
- self.fqdn = None
- self.program = None
- self.version = None
- self.extra = {}
def updateFromData(self, data):
"""Update worker information if contained in the WORK_DATA response."""
self.name = data.get('worker_name', self.name)
self.hostname = data.get('worker_hostname', self.hostname)
- self.ips = data.get('worker_ips', self.ips)
- self.fqdn = data.get('worker_fqdn', self.fqdn)
- self.program = data.get('worker_program', self.program)
- self.version = data.get('worker_version', self.version)
- self.extra = data.get('worker_extra', self.extra)
def __repr__(self):
return '<Worker %s>' % self.name
@@ -1322,7 +1312,7 @@
def __init__(self, queue, change):
self.pipeline = queue.pipeline
self.queue = queue
- self.change = change # a changeish
+ self.change = change # a ref
self.build_sets = []
self.dequeued_needing_change = False
self.current_build_set = BuildSet(self)
@@ -1631,15 +1621,14 @@
return (result, url)
def formatJSON(self):
- changeish = self.change
ret = {}
ret['active'] = self.active
ret['live'] = self.live
- if hasattr(changeish, 'url') and changeish.url is not None:
- ret['url'] = changeish.url
+ if hasattr(self.change, 'url') and self.change.url is not None:
+ ret['url'] = self.change.url
else:
ret['url'] = None
- ret['id'] = changeish._id()
+ ret['id'] = self.change._id()
if self.item_ahead:
ret['item_ahead'] = self.item_ahead.change._id()
else:
@@ -1647,8 +1636,8 @@
ret['items_behind'] = [i.change._id() for i in self.items_behind]
ret['failing_reasons'] = self.current_build_set.failing_reasons
ret['zuul_ref'] = self.current_build_set.ref
- if changeish.project:
- ret['project'] = changeish.project.name
+ if self.change.project:
+ ret['project'] = self.change.project.name
else:
# For cross-project dependencies with the depends-on
# project not known to zuul, the project is None
@@ -1656,8 +1645,8 @@
ret['project'] = "Unknown Project"
ret['enqueue_time'] = int(self.enqueue_time * 1000)
ret['jobs'] = []
- if hasattr(changeish, 'owner'):
- ret['owner'] = changeish.owner
+ if hasattr(self.change, 'owner'):
+ ret['owner'] = self.change.owner
else:
ret['owner'] = None
max_remaining = 0
@@ -1688,11 +1677,6 @@
worker = {
'name': build.worker.name,
'hostname': build.worker.hostname,
- 'ips': build.worker.ips,
- 'fqdn': build.worker.fqdn,
- 'program': build.worker.program,
- 'version': build.worker.version,
- 'extra': build.worker.extra
}
if remaining and remaining > max_remaining:
max_remaining = remaining
@@ -1725,20 +1709,19 @@
return ret
def formatStatus(self, indent=0, html=False):
- changeish = self.change
indent_str = ' ' * indent
ret = ''
- if html and hasattr(changeish, 'url') and changeish.url is not None:
+ if html and getattr(self.change, 'url', None) is not None:
ret += '%sProject %s change <a href="%s">%s</a>\n' % (
indent_str,
- changeish.project.name,
- changeish.url,
- changeish._id())
+ self.change.project.name,
+ self.change.url,
+ self.change._id())
else:
ret += '%sProject %s change %s based on %s\n' % (
indent_str,
- changeish.project.name,
- changeish._id(),
+ self.change.project.name,
+ self.change._id(),
self.item_ahead)
for job in self.getJobs():
build = self.current_build_set.getBuild(job.name)
@@ -1809,6 +1792,8 @@
self.oldrev = None
self.newrev = None
+ self.files = []
+
def getBasePath(self):
base_path = ''
if hasattr(self, 'ref'):
@@ -1851,6 +1836,8 @@
return set()
def updatesConfig(self):
+ if 'zuul.yaml' in self.files or '.zuul.yaml' in self.files:
+ return True
return False
def getSafeAttributes(self):
@@ -1870,7 +1857,6 @@
self.patchset = None
self.refspec = None
- self.files = []
self.needs_changes = []
self.needed_by_changes = []
self.is_current_patchset = True
@@ -1918,11 +1904,6 @@
related.update(c.getRelatedChanges())
return related
- def updatesConfig(self):
- if 'zuul.yaml' in self.files or '.zuul.yaml' in self.files:
- return True
- return False
-
def getSafeAttributes(self):
return Attributes(project=self.project,
number=self.number,
@@ -1936,6 +1917,7 @@
self.data = None
# common
self.type = None
+ self.branch_updated = False
# For management events (eg: enqueue / promote)
self.tenant_name = None
self.project_hostname = None
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 61f1e5f..a63d270 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -228,6 +228,7 @@
self.zuul_version = zuul_version.version_info.release_string()
self.last_reconfigured = None
+ self.tenant_last_reconfigured = {}
def stop(self):
self._stopped = True
@@ -590,6 +591,7 @@
trigger.postConfig(pipeline)
for reporter in pipeline.actions:
reporter.postConfig()
+ self.tenant_last_reconfigured[tenant.name] = int(time.time())
if self.statsd:
try:
for pipeline in tenant.layout.pipelines.values():
@@ -747,7 +749,7 @@
"source %s",
e.change, project.source)
continue
- if (event.type == 'change-merged' and
+ if (event.branch_updated and
hasattr(change, 'files') and
change.updatesConfig()):
# The change that just landed updates the config.