Merge "Pass zuul_success to cleanup playbooks"
This commit is contained in:
commit
c9227360e2
|
@ -1874,8 +1874,8 @@ class RecordingAnsibleJob(zuul.executor.server.AnsibleJob):
|
||||||
self.recordResult(None)
|
self.recordResult(None)
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
def runCleanupPlaybooks(self):
|
def runCleanupPlaybooks(self, success):
|
||||||
super(RecordingAnsibleJob, self).runCleanupPlaybooks()
|
super(RecordingAnsibleJob, self).runCleanupPlaybooks(success)
|
||||||
if self.result is not None:
|
if self.result is not None:
|
||||||
self.recordResult(self.result)
|
self.recordResult(self.result)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- hosts: all
|
- hosts: all
|
||||||
tasks:
|
tasks:
|
||||||
- file:
|
- copy:
|
||||||
path: "{{zuul._test.test_root}}/{{zuul.build}}.cleanup.flag"
|
content: "{{ zuul_success }}"
|
||||||
state: touch
|
dest: "{{ zuul._test.test_root }}/{{ zuul.build }}.cleanup.flag"
|
||||||
|
|
|
@ -2925,6 +2925,8 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase):
|
||||||
cleanup_flag = os.path.join(self.test_root, build.uuid +
|
cleanup_flag = os.path.join(self.test_root, build.uuid +
|
||||||
'.cleanup.flag')
|
'.cleanup.flag')
|
||||||
self.assertTrue(os.path.exists(cleanup_flag))
|
self.assertTrue(os.path.exists(cleanup_flag))
|
||||||
|
with open(cleanup_flag) as f:
|
||||||
|
self.assertEqual('True', f.readline())
|
||||||
|
|
||||||
def test_cleanup_playbook_failure(self):
|
def test_cleanup_playbook_failure(self):
|
||||||
# Test that the cleanup run is performed
|
# Test that the cleanup run is performed
|
||||||
|
@ -2950,6 +2952,8 @@ class TestCleanupPlaybooks(AnsibleZuulTestCase):
|
||||||
cleanup_flag = os.path.join(self.test_root, build.uuid +
|
cleanup_flag = os.path.join(self.test_root, build.uuid +
|
||||||
'.cleanup.flag')
|
'.cleanup.flag')
|
||||||
self.assertTrue(os.path.exists(cleanup_flag))
|
self.assertTrue(os.path.exists(cleanup_flag))
|
||||||
|
with open(cleanup_flag) as f:
|
||||||
|
self.assertEqual('False', f.readline())
|
||||||
|
|
||||||
def test_cleanup_playbook_abort(self):
|
def test_cleanup_playbook_abort(self):
|
||||||
# Test that when we abort a job the cleanup run is performed
|
# Test that when we abort a job the cleanup run is performed
|
||||||
|
|
|
@ -998,8 +998,9 @@ class AnsibleJob(object):
|
||||||
self.job.sendWorkStatus(0, 100)
|
self.job.sendWorkStatus(0, 100)
|
||||||
|
|
||||||
result = self.runPlaybooks(args)
|
result = self.runPlaybooks(args)
|
||||||
|
success = result == 'SUCCESS'
|
||||||
|
|
||||||
self.runCleanupPlaybooks()
|
self.runCleanupPlaybooks(success)
|
||||||
|
|
||||||
# Stop the persistent SSH connections.
|
# Stop the persistent SSH connections.
|
||||||
setup_status, setup_code = self.runAnsibleCleanup(
|
setup_status, setup_code = self.runAnsibleCleanup(
|
||||||
|
@ -1294,7 +1295,7 @@ class AnsibleJob(object):
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def runCleanupPlaybooks(self):
|
def runCleanupPlaybooks(self, success):
|
||||||
if not self.jobdir.cleanup_playbooks:
|
if not self.jobdir.cleanup_playbooks:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1310,7 +1311,7 @@ class AnsibleJob(object):
|
||||||
for index, playbook in enumerate(self.jobdir.cleanup_playbooks):
|
for index, playbook in enumerate(self.jobdir.cleanup_playbooks):
|
||||||
self.runAnsiblePlaybook(
|
self.runAnsiblePlaybook(
|
||||||
playbook, cleanup_timeout, self.ansible_version,
|
playbook, cleanup_timeout, self.ansible_version,
|
||||||
phase='cleanup', index=index)
|
success=success, phase='cleanup', index=index)
|
||||||
|
|
||||||
def _logFinalPlaybookError(self):
|
def _logFinalPlaybookError(self):
|
||||||
# Failures in the final post playbook can include failures
|
# Failures in the final post playbook can include failures
|
||||||
|
|
Loading…
Reference in New Issue