Exemplo n.º 1
0
    def tasks(self):
        """Get a list of all the taskcluster tasks for web-platform-tests
        jobs associated with the current try push.

        :return: List of tasks
        """
        task_id = tc.normalize_task_id(self.taskgroup_id)
        if task_id != self.taskgroup_id:
            self.taskgroup_id = task_id

        tasks = tc.TaskGroup(self.taskgroup_id)
        tasks.refresh()

        return TryPushTasks(tasks)
Exemplo n.º 2
0
    def __call__(self, git_gecko, git_wpt, body):
        newrelic.agent.set_transaction_name("TaskGroupHandler")
        taskgroup_id = tc.normalize_task_id(body["taskGroupId"])

        newrelic.agent.add_custom_parameter("tc_task", taskgroup_id)

        try_push = trypush.TryPush.for_taskgroup(git_gecko, taskgroup_id)
        if not try_push:
            logger.debug("No try push for taskgroup %s" % taskgroup_id)
            # this is not one of our try_pushes
            return
        logger.info("Found try push for taskgroup %s" % taskgroup_id)
        sync = try_push.sync(git_gecko, git_wpt)

        with SyncLock.for_process(sync.process_name) as lock:
            with sync.as_mut(lock), try_push.as_mut(lock):
                # We sometimes see the taskgroup ID being None. If it isn't set but found via its
                # taskgroup ID, it is safe to set it here.
                if try_push.taskgroup_id is None:
                    logger.info(
                        "Try push for taskgroup %s does not have its ID set, setting now"
                        % taskgroup_id)
                    try_push.taskgroup_id = taskgroup_id
                    newrelic.agent.record_custom_event("taskgroup_id_missing",
                                                       params={
                                                           "taskgroup-id":
                                                           taskgroup_id,
                                                           "try_push":
                                                           try_push,
                                                           "sync": sync,
                                                       })
                elif try_push.taskgroup_id != taskgroup_id:
                    msg = (
                        "TryPush %s, expected taskgroup ID %s, found %s instead"
                        % (try_push, taskgroup_id, try_push.taskgroup_id))
                    logger.error(msg)
                    exc = ValueError(msg)
                    newrelic.agent.record_exception(exc=exc)
                    raise exc

                if sync:
                    logger.info("Updating try push for sync %r" % sync)
                if isinstance(sync, downstream.DownstreamSync):
                    downstream.try_push_complete(git_gecko, git_wpt, try_push,
                                                 sync)
                elif isinstance(sync, landing.LandingSync):
                    landing.try_push_complete(git_gecko, git_wpt, try_push,
                                              sync)
Exemplo n.º 3
0
    def __call__(self, git_gecko, git_wpt, body):
        sha1 = body["origin"]["revision"]
        task_id = tc.normalize_task_id(body["taskId"])
        state = body["state"]
        result = body["result"]

        try_push = trypush.TryPush.for_commit(git_gecko, sha1)
        if not try_push:
            logger.debug("No try push for SHA1 %s taskId %s" % (sha1, task_id))
            return

        # Enforce the invariant that the taskgroup id is not set until
        # the decision task is complete. This allows us to determine if a
        # try push should have the expected wpt tasks just by checking if
        # this is set
        if state != "completed" or result == "superseded":
            logger.info("Decision task is not yet complete, status %s" %
                        result)
            return

        # If we retrigger, we create a new taskgroup, with id equal to the new task_id.
        # But the retriggered decision task itself is still in the original taskgroup
        if result == "success":
            logger.info("Setting taskgroup id for try push %r to %s" %
                        (try_push, task_id))
            try_push.taskgroup_id = task_id
        elif result in ("fail", "exception"):
            sync = try_push.sync(git_gecko, git_wpt)
            message = (
                "Decision task got status %s for task %s%s" %
                (result, sha1, " PR %s" % sync.pr if sync and sync.pr else ""))
            logger.error(message)
            task = tc.get_task(task_id)
            taskgroup = tc.TaskGroup(task["taskGroupId"])
            if len(
                    taskgroup.view(lambda x: x["metadata"]["name"] ==
                                   "Gecko Decision Task")) > 5:
                try_push.status = "complete"
                try_push.infra_fail = True
                if sync and sync.bug:
                    # TODO this is commenting too frequently on bugs
                    env.bz.comment(
                        sync.bug,
                        "Try push failed: decision task %i returned error" %
                        task_id)
            else:
                client = tc.TaskclusterClient()
                client.retrigger(task_id)
Exemplo n.º 4
0
def do_download_logs(git_gecko, git_wpt, log_path, taskgroup_id, **kwargs):
    import tc
    import trypush
    import tempfile

    if log_path is None:
        log_path = tempfile.mkdtemp()

    taskgroup_id = tc.normalize_task_id(taskgroup_id)

    tasks = tc.TaskGroup(taskgroup_id)
    tasks.refresh()

    try_tasks = trypush.TryPushTasks(tasks)
    try_tasks.wpt_tasks.download_logs(os.path.join(log_path, taskgroup_id),
                                      ["wptreport.json"])
Exemplo n.º 5
0
    def __call__(self, git_gecko, git_wpt, body):
        taskgroup_id = tc.normalize_task_id(body["taskGroupId"])

        try_push = trypush.TryPush.for_taskgroup(git_gecko, taskgroup_id)
        if not try_push:
            logger.debug("No try push for taskgroup %s" % taskgroup_id)
            # this is not one of our try_pushes
            return
        logger.info("Found try push for taskgroup %s" % taskgroup_id)
        sync = try_push.sync(git_gecko, git_wpt)
        if sync:
            logger.info("Updating try push for sync %r" % sync)
        if isinstance(sync, downstream.DownstreamSync):
            downstream.try_push_complete(git_gecko, git_wpt, try_push, sync)
        elif isinstance(sync, landing.LandingSync):
            landing.try_push_complete(git_gecko, git_wpt, try_push, sync)
Exemplo n.º 6
0
    def tasks(self, force_update=False):
        """Get a list of all the taskcluster tasks for web-platform-tests
        jobs associated with the current try push.

        :param bool force_update: Force the tasks to be refreshed from the
                                  server
        :return: List of tasks
        """
        if not force_update and "tasks" in self._data:
            tasks = tc.TaskGroup(self.taskgroup_id, self._data["tasks"])
        else:
            task_id = tc.normalize_task_id(self.taskgroup_id)
            if task_id != self.taskgroup_id:
                self.taskgroup_id = task_id

            tasks = tc.TaskGroup(self.taskgroup_id)
            tasks.refresh()

        if tasks.view().is_complete(allow_unscheduled=True):
            self._data["tasks"] = tasks.tasks
        return tasks