def StartNewBisectForBug(bug_id): """Tries to trigger a bisect job for the alerts associated with a bug. Args: bug_id: A bug ID number. Returns: If successful, a dict containing "issue_id" and "issue_url" for the bisect job. Otherwise, a dict containing "error", with some description of the reason why a job wasn't started. """ try: bisect_job = _MakeBisectTryJob(bug_id) except NotBisectableError as e: logging.info('New bisect errored out with message: ' + e.message) return {'error': e.message} bisect_job_key = bisect_job.put() try: bisect_result = start_try_job.PerformBisect(bisect_job) except request_handler.InvalidInputError as e: bisect_result = {'error': e.message} if 'error' in bisect_result: bisect_job_key.delete() return bisect_result
def _RestartFailedBisectJobs(): """Restarts failed bisect jobs. Bisect jobs that ran out of retries will be deleted. Returns: True if all bisect jobs that were retried were successfully triggered, and False otherwise. """ bisect_jobs = try_job.TryJob.query(try_job.TryJob.status == 'failed').fetch() all_successful = True for job in bisect_jobs: if job.run_count > 0: if job.run_count <= len(_BISECT_RESTART_PERIOD_DAYS): if _IsBisectJobDueForRestart(job): # Start bisect right away if this is the first retry. Otherwise, # try bisect with different config. if job.run_count == 1: try: start_try_job.PerformBisect(job) except request_handler.InvalidInputError as e: logging.error(e.message) all_successful = False elif job.bug_id: restart_successful = _RestartBisect(job) if not restart_successful: all_successful = False else: if job.bug_id: comment = ('Failed to run bisect %s times.' 'Stopping automatic restart for this job.' % job.run_count) start_try_job.LogBisectResult(job.bug_id, comment) job.key.delete() return all_successful
def _StartBisectFYIJob(test_name, bisect_config): """Re-starts a bisect-job after modifying it's config based on run count. Args: test_name: Name of the test case. bisect_job: TryJob entity with initialized bot name and config. Returns: If successful, a dict containing "issue_id" and "issue_url" for the bisect job. Otherwise, a dict containing "error", with some description of the reason why a job wasn't started. """ try: bisect_job = _MakeBisectFYITryJob(test_name, bisect_config) except auto_bisect.NotBisectableError as e: return {'error': e.message} try: bisect_result = start_try_job.PerformBisect(bisect_job) except request_handler.InvalidInputError as e: bisect_result = {'error': e.message} if 'error' in bisect_result: if bisect_job.key: bisect_job.key.delete() return bisect_result
def testPerformBisect_InvalidConfig_ReturnsError(self): bisect_job = try_job.TryJob(bot='foo', config='config = {}', master_name='ChromiumPerf', internal_only=False, job_type='bisect') self.assertEqual({'error': 'No "recipe_tester_name" given.'}, start_try_job.PerformBisect(bisect_job))
def _StartRecipeBisect(bug_id, test_anomaly, test): bisect_job = _MakeBisectTryJob(bug_id, test_anomaly, test) bisect_job_key = bisect_job.put() try: bisect_result = start_try_job.PerformBisect(bisect_job) except request_handler.InvalidInputError as e: bisect_result = {'error': e.message} if 'error' in bisect_result: bisect_job_key.delete() return bisect_result
def _RestartBisect(bisect_job): """Re-starts a bisect-job after modifying it's config based on run count. Args: bisect_job: TryJob entity with initialized bot name and config. """ try: new_bisect_job = _MakeBisectTryJob( bisect_job.bug_id, bisect_job.run_count) except NotBisectableError: return bisect_job.config = new_bisect_job.config bisect_job.bot = new_bisect_job.bot bisect_job.put() start_try_job.PerformBisect(bisect_job)
def StartNewBisectForBug(bug_id): """Tries to trigger a bisect job for the alerts associated with a bug. Args: bug_id: A bug ID number. Returns: If successful, a dict containing "issue_id" and "issue_url" for the bisect job. Otherwise, a dict containing "error". """ try: bisect_job = _MakeBisectTryJob(bug_id) except NotBisectableError as e: return {'error': e.message} bisect_job_key = bisect_job.put() bisect_result = start_try_job.PerformBisect(bisect_job) if 'error' in bisect_result: bisect_job_key.delete() return bisect_result
def _RestartBisect(bisect_job): """Re-starts a bisect-job after modifying it's config based on run count. Args: bisect_job: TryJob entity with initialized bot name and config. """ if bisect_job.use_buildbucket and (bisect_job.bot_name not in _FORCED_RECIPE_BOTS): # Buildbucket bisects other than thos in _FORCED_RECIPE_BOTS are not # automatically retried. return try: new_bisect_job = _MakeBisectTryJob( bisect_job.bug_id, bisect_job.run_count) except NotBisectableError: return bisect_job.config = new_bisect_job.config bisect_job.bot = new_bisect_job.bot bisect_job.put() start_try_job.PerformBisect(bisect_job)
def _RestartFailedBisectJobs(): """Restarts failed bisect jobs. Bisect jobs that ran out of retries will be deleted. """ bisect_jobs = try_job.TryJob.query(try_job.TryJob.status == 'failed').fetch() for job in bisect_jobs: if job.run_count > 0: if job.run_count <= len(_BISECT_RESTART_PERIOD_DAYS): if _IsBisectJobDueForRestart(job): if job.run_count == 1: start_try_job.PerformBisect(job) elif job.bug_id: _RestartBisect(job) else: if job.bug_id: comment = ('Failed to run bisect %s times.' 'Stopping automatic restart for this job.' % job.run_count) start_try_job.LogBisectResult(job.bug_id, comment) job.key.delete()
def _RestartBisect(bisect_job): """Re-starts a bisect-job after modifying it's config based on run count. Args: bisect_job: TryJob entity with initialized bot name and config. Returns: True if the bisect was successfully triggered and False otherwise. """ try: new_bisect_job = _MakeBisectTryJob(bisect_job.bug_id, bisect_job.run_count) except NotBisectableError: return False bisect_job.config = new_bisect_job.config bisect_job.bot = new_bisect_job.bot bisect_job.put() try: start_try_job.PerformBisect(bisect_job) except request_handler.InvalidInputError as e: logging.error(e.message) return False return True