Esempio n. 1
0
    def parse(self, request, project, jm, pk=None):
        """Trigger an async task to parse this log."""
        log_obj = jm.get_job_log_url_detail(pk)
        job = jm.get_job(log_obj["job_id"])[0]

        logger.info("{0} has requested to parse log {1}".format(
            request.user.username, log_obj))

        # importing here to avoid an import loop
        from treeherder.log_parser.tasks import parse_log
        parse_log.apply_async(args=[project, log_obj, job["job_guid"]],
                              routing_key='parse_log.high_priority')

        return Response({"message": "Log parsing triggered successfully"})
Esempio n. 2
0
    def parse(self, request, project, jm, pk=None):
        """Trigger an async task to parse this log."""
        log_obj = jm.get_job_log_url_detail(pk)
        job = jm.get_job(log_obj["job_id"])[0]

        logger.info("{0} has requested to parse log {1}".format(
                    request.user.username, log_obj))

        # importing here to avoid an import loop
        from treeherder.log_parser.tasks import parse_log
        parse_log.apply_async(
            args=[project, log_obj, job["job_guid"]],
            routing_key='parse_log.high_priority'
        )

        return Response({"message": "Log parsing triggered successfully"})
Esempio n. 3
0
    def _load_log_urls(self, log_placeholders, job_id_lookup, job_results):

        # importing here to avoid an import loop
        from treeherder.log_parser.tasks import parse_log

        tasks = []

        if log_placeholders:
            for index, log_ref in enumerate(log_placeholders):
                job_guid = log_placeholders[index][0]
                job_id = job_id_lookup[job_guid]["id"]
                result = job_results[job_guid]
                result_set_id = job_id_lookup[job_guid]["result_set_id"]

                # Replace job_guid with id
                log_placeholders[index][0] = job_id

                task = dict()
                task["id"] = job_id
                task["result_set_id"] = result_set_id
                if result != "success":
                    task["check_errors"] = True
                    task["routing_key"] = "parse_log.failures"
                else:
                    task["check_errors"] = False
                    task["routing_key"] = "parse_log.success"
                tasks.append(task)

            # Store the log references
            self.get_jobs_dhub().execute(
                proc="jobs.inserts.set_job_log_url",
                debug_show=self.DEBUG,
                placeholders=log_placeholders,
                executemany=True,
            )

            for task in tasks:
                parse_log.apply_async(
                    args=[self.project, task["id"], task["result_set_id"]],
                    kwargs={"check_errors": task["check_errors"]},
                    routing_key=task["routing_key"],
                )