def added(cls, attachment_id, queue_name): PatchLog.lookup(attachment_id, queue_name) queue_log = QueueLog.get_current(queue_name, queue_log_duration) patches_waiting = cls._get_patches_waiting(queue_name) if patches_waiting and queue_log.max_patches_waiting < patches_waiting: queue_log.max_patches_waiting = patches_waiting queue_log.put()
def _build_message_for_provisional_failure(self, queue, attachment, queue_position, statuses): patch_log = PatchLog.lookup_if_exists(attachment.id, queue.name()) if not patch_log: return "Internal error. No PatchLog entry in database." is_active = attachment.id in queue.active_work_items().item_ids try_count = patch_log.retry_count + (not is_active) # retry_count is updated when a new attempt starts. latest_resultative_status = self._latest_resultative_status(statuses) tree_is_red = latest_resultative_status.message == "Unable to pass tests without patch (tree is red?)" or latest_resultative_status.message == "Unable to build without patch" message = latest_resultative_status.message + "." if is_active: if tree_is_red: message += "\n\nTrying again now." else: message += "\n\nThis result is not final, as the issue could be a pre-existing one. Trying to determine that now." if try_count == 1: message += "\n\nPreviously completed a round of testing, but couldn't arrive at a definitive conclusion." elif try_count > 1: message += "\n\nPreviously completed " + str(try_count) + " rounds of testing, but couldn't arrive at a definitive conclusion." else: real_queue_position = self._real_queue_position(queue, queue_position) if tree_is_red: message += "\n\nWill try again, currently #" + str(real_queue_position) + " in queue." else: message += "\n\nThis result is not final, as the issue can be a pre-existing one. " if try_count == 1: message += "Completed one round " else: message += "Completed " + str(try_count) + " rounds " message += "of testing trying to determine that, but couldn't arrive at a definitive conclusion yet.\n\nWill try again, currently #" + str(real_queue_position) + " in queue." message += "\n\nPlease click the bubble for detailed results.\n\n" + self._iso_time(statuses[0].date) return message
def stopped(cls, attachment_id, queue_name, status_message, bot_id=None): patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name) if not patch_log: WarningLog.record("patchlog missing", "In stopped event.", attachment_id, queue_name, bot_id) return if patch_log.wait_duration is None: WarningLog.record("patchlog wait duration missing", "In stopped event.", attachment_id, queue_name, bot_id) return if not patch_log.finished: if bot_id: patch_log.bot_id = bot_id patch_log.finished = True patch_log.calculate_process_duration() patch_log.latest_message = status_message patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_process_durations.append( patch_log.process_duration) queue_log.put()
def started(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name) if not patch_log: WarningLog.record("patchlog missing", "In started event.", attachment_id, queue_name, bot_id) return if bot_id: patch_log.bot_id = bot_id # An existing wait_duration implies the patch had been started previously and is # being picked up again because it had expired, or was released. if patch_log.wait_duration is not None: patch_log.retry_count += 1 patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_retry_count += 1 queue_log.put() else: patch_log.calculate_wait_duration() patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_wait_durations.append(patch_log.wait_duration) queue_log.put()
def _get_patch_logs(self, queue_name, timestamp, view_range): patch_log_query = PatchLog.all() patch_log_query = patch_log_query.filter("queue_name =", queue_name) patch_log_query = patch_log_query.filter("date >=", datetime.utcfromtimestamp(timestamp - view_range)) patch_log_query = patch_log_query.filter("date <=", datetime.utcfromtimestamp(timestamp)) patch_log_query = patch_log_query.order("date") return patch_log_query.run(limit=charts.patch_log_limit)
def _get_patch_logs(self, queue_name, timestamp, view_range): patch_log_query = PatchLog.all() patch_log_query = patch_log_query.filter("queue_name =", queue_name) patch_log_query = patch_log_query.filter( "date >=", datetime.utcfromtimestamp(timestamp - view_range)) patch_log_query = patch_log_query.filter( "date <=", datetime.utcfromtimestamp(timestamp)) patch_log_query = patch_log_query.order("date") return patch_log_query.run(limit=charts.patch_log_limit)
def retrying(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup(attachment_id, queue_name) if bot_id: patch_log.bot_id = bot_id patch_log.retry_count += 1 patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_retry_count += 1 queue_log.put()
def updated(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup(attachment_id, queue_name) if bot_id: patch_log.bot_id = bot_id patch_log.status_update_count += 1 patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.status_update_count += 1 queue_log.put()
def started(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup(attachment_id, queue_name) if bot_id: patch_log.bot_id = bot_id patch_log.calculate_wait_duration() patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_wait_durations.append(patch_log.wait_duration) queue_log.put()
def stopped(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup(attachment_id, queue_name) if bot_id: patch_log.bot_id = bot_id patch_log.finished = True patch_log.calculate_process_duration() patch_log.put() if patch_log.process_duration: queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_process_durations.append(patch_log.process_duration) queue_log.put()
def _fetch_patch_log(self, start_date, end_date): all_entries = PatchLog.all().filter('date >', start_date).filter('date <', end_date).fetch(limit=None) result = {} for entry in all_entries: result.setdefault(entry.attachment_id, {}) result[entry.attachment_id][entry.queue_name] = { "date": entry.date, "wait_duration": entry.wait_duration, "process_duration": entry.process_duration, "retry_count": entry.retry_count, "resolution": self._resultFromFinalStatus(entry.latest_message, entry.queue_name) if entry.finished else "in progress" } return result
def updated(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name) if not patch_log: WarningLog.record("patchlog missing", "In updated event.", attachment_id, queue_name, bot_id) return if bot_id: patch_log.bot_id = bot_id patch_log.status_update_count += 1 patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.status_update_count += 1 queue_log.put()
def _rows_for_work_items(self, queue): queued_items = queue.work_items() active_items = queue.active_work_items() if not queued_items: return [] rows = [] for item_id in queued_items.item_ids: patchStatusQuery = QueueStatus.all().filter( 'queue_name =', queue.name()).filter('active_patch_id =', item_id).order('-date') statuses = patchStatusQuery.fetch(1) message = None message_time = None bug_id = None results_url = None if statuses: message = statuses[0].message message_time = statuses[0].date bug_id = statuses[0].active_bug_id results_url = self.request.host_url + "/results/" + str( statuses[0].key(). id()) if statuses[0].results_file else None row = { "attachment_id": item_id, "bug_id": bug_id, "active": active_items and active_items.time_for_item(item_id) != None, "active_since": active_items and active_items.time_for_item(item_id), "latest_message": message, "latest_message_time": message_time, "status_page": self.request.host_url + "/patch/" + str(item_id), "latest_results": results_url, } patch_log = PatchLog.lookup_if_exists(item_id, queue.name()) if patch_log and patch_log.retry_count: row["retry_count"] = patch_log.retry_count rows.append(row) return rows
def _rows_for_work_items(self, queue): queued_items = queue.work_items() active_items = queue.active_work_items() if not queued_items: return [] rows = [] for item_id in queued_items.item_ids: patchStatusQuery = QueueStatus.all().filter( 'queue_name =', queue.name()).filter('active_patch_id =', item_id).order('-date') statuses = patchStatusQuery.fetch(1) message = None message_time = None bug_id = None results_url = None if statuses: message = statuses[0].message message_time = statuses[0].date bug_id = statuses[0].active_bug_id results_url = self.request.host_url + "/results/" + str( statuses[0].key().id( )) if statuses[0].results_file else None row = { "attachment_id": item_id, "bug_id": bug_id, "active": active_items and active_items.time_for_item(item_id) != None, "active_since": active_items and active_items.time_for_item(item_id), "latest_message": message, "latest_message_time": message_time, "status_page": self.request.host_url + "/patch/" + str(item_id), "latest_results": results_url, } patch_log = PatchLog.lookup_if_exists(item_id, queue.name()) if patch_log and patch_log.retry_count: row["retry_count"] = patch_log.retry_count rows.append(row) return rows
def stopped(cls, attachment_id, queue_name, bot_id=None): patch_log = PatchLog.lookup_if_exists(attachment_id, queue_name) if not patch_log: WarningLog.record("patchlog missing", "In stopped event.", attachment_id, queue_name, bot_id) return if not patch_log.wait_duration: WarningLog.record("patchlog wait duration missing", "In stopped event.", attachment_id, queue_name, bot_id) return if not patch_log.finished: if bot_id: patch_log.bot_id = bot_id patch_log.finished = True patch_log.calculate_process_duration() patch_log.put() queue_log = QueueLog.get_current(queue_name, queue_log_duration) queue_log.patch_process_durations.append(patch_log.process_duration) queue_log.put()
def added(cls, attachment_id, queue_name): PatchLog.lookup(attachment_id, queue_name) queue_log = QueueLog.get_current(queue_name, queue_log_duration) if queue_log.update_max_patches_waiting(): queue_log.put()