Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # coding=utf8 | 1 # coding=utf8 |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 """Sends patches to the Try server and reads back results. | 5 """Sends patches to the Try server and reads back results. |
| 6 | 6 |
| 7 - RietveldTryJobs contains RietveldTryJob, one per try job on a builder. | 7 - RietveldTryJobs contains RietveldTryJob, one per try job on a builder. |
| 8 - TryRunnerRietveld uses Rietveld to signal and poll job results. | 8 - TryRunnerRietveld uses Rietveld to signal and poll job results. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import collections | 11 import collections |
| 12 import errno | |
| 12 import logging | 13 import logging |
| 13 import re | 14 import re |
| 15 import socket | |
| 14 import time | 16 import time |
| 15 import urllib2 | 17 import urllib2 |
| 16 | 18 |
| 17 import buildbot_json | 19 import buildbot_json |
| 18 import model | 20 import model |
| 19 from verification import base | 21 from verification import base |
| 20 from verification import try_job_steps | 22 from verification import try_job_steps |
| 21 | 23 |
| 22 # A build running for longer than this is considered to be timed out. | 24 # A build running for longer than this is considered to be timed out. |
| 23 TIMED_OUT = 12 * 60 * 60 | 25 TIMED_OUT = 12 * 60 * 60 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 self.send_status(pending, info) | 768 self.send_status(pending, info) |
| 767 | 769 |
| 768 def _update_jobs_from_rietveld(self, pending, jobs, handle, now): | 770 def _update_jobs_from_rietveld(self, pending, jobs, handle, now): |
| 769 """Grabs data from Rietveld and pass it to | 771 """Grabs data from Rietveld and pass it to |
| 770 RietveldTryJobs.update_jobs_from_rietveld(). | 772 RietveldTryJobs.update_jobs_from_rietveld(). |
| 771 | 773 |
| 772 Returns True on success. | 774 Returns True on success. |
| 773 """ | 775 """ |
| 774 status = buildbot_json.Buildbot(self.try_server_url) | 776 status = buildbot_json.Buildbot(self.try_server_url) |
| 775 try: | 777 try: |
| 776 data = self.context.rietveld.get_patchset_properties( | 778 try: |
| 777 pending.issue, pending.patchset) | 779 data = self.context.rietveld.get_patchset_properties( |
| 780 pending.issue, pending.patchset) | |
| 781 except urllib2.HTTPError as e: | |
| 782 if e.code == 404: | |
| 783 # TODO(phajdan.jr): Maybe generate a random id to correlate the user's | |
| 784 # error message and exception in the logs. | |
| 785 # Don't put exception traceback in the user-visible message to avoid | |
| 786 # leaking sensitive CQ data (passwords etc). | |
| 787 jobs.error_message = ('Failed to get patchset properties (patchset ' | |
| 788 'not found?)') | |
| 789 logging.error(str(e)) | |
| 790 return False | |
| 791 else: | |
|
Isaac (away)
2013/10/24 17:25:41
Would this make more sense for rietveld.py to hand
Paweł Hajdan Jr.
2013/10/24 18:28:12
I don't think so. If anything, it might be better
Isaac (away)
2013/10/24 19:01:33
Python 3 supports native exception chaining. In P
| |
| 792 raise | |
| 793 | |
| 794 # Update the RietvedTryJobs object. | |
| 795 keys = jobs.update_jobs_from_rietveld( | |
| 796 pending.owner, | |
| 797 pending.issue, | |
| 798 data, | |
| 799 status, | |
| 800 self.context.checkout, | |
| 801 now) | |
| 778 except urllib2.HTTPError as e: | 802 except urllib2.HTTPError as e: |
| 779 if e.code == 404: | 803 if e.code in (500, 502, 503): |
| 780 # TODO(phajdan.jr): Maybe generate a random id to correlate the user's | |
| 781 # error message and exception in the logs. | |
| 782 # Don't put exception traceback in the user-visible message to avoid | |
| 783 # leaking sensitive CQ data (passwords etc). | |
| 784 jobs.error_message = ('Failed to get patchset properties (patchset ' | |
| 785 'not found?)') | |
| 786 logging.error(str(e)) | |
| 787 return False | |
| 788 elif e.code == 500: | |
| 789 # Temporary AppEngine hiccup. Just log it and return failure. | 804 # Temporary AppEngine hiccup. Just log it and return failure. |
| 790 logging.warning(str(e)) | 805 logging.warning(str(e)) |
| 791 return False | 806 return False |
| 792 else: | 807 else: |
| 793 raise | 808 raise |
| 794 # Update the RietvedTryJobs object. | 809 except socket.error as e: |
| 795 keys = jobs.update_jobs_from_rietveld( | 810 # Temporary AppEngine hiccup. Just log it and return failure. |
| 796 pending.owner, pending.issue, data, status, self.context.checkout, now) | 811 if e.errno == errno.ECONNRESET: |
|
Isaac (away)
2013/10/24 17:25:41
We're now raising if this doesn't match?
Paweł Hajdan Jr.
2013/10/24 18:28:12
If we're catching it here it means something in th
| |
| 812 logging.warning(str(e)) | |
| 813 return False | |
| 814 else: | |
| 815 raise | |
| 797 if handle: | 816 if handle: |
| 798 for updated_key in keys: | 817 for updated_key in keys: |
| 799 job = jobs.try_jobs[updated_key] | 818 job = jobs.try_jobs[updated_key] |
| 800 self._update_dashboard(pending, job, status) | 819 self._update_dashboard(pending, job, status) |
| 801 jobs.signal_as_failed_if_needed(job, self._build_status_url(job), now) | 820 jobs.signal_as_failed_if_needed(job, self._build_status_url(job), now) |
| 802 | 821 |
| 803 return True | 822 return True |
| OLD | NEW |