Beispiel #1
0
    def cancel_all(self, request, project, pk=None):
        """
        Cancel all pending and running jobs in this resultset
        """
        if not pk:  # pragma nocover
            return Response({"message": "resultset id required"}, status=HTTP_400_BAD_REQUEST)

        # Sending 'cancel_all' action to pulse. Right now there is no listener
        # for this, so we cannot remove 'cancel' action for each job below.
        publish_resultset_action.apply_async(
            args=[project, 'cancel_all', pk, request.user.email],
            routing_key='publish_to_pulse'
        )

        # Notify the build systems which created these jobs...
        for job in Job.objects.filter(push_id=pk).exclude(state='completed'):
            publish_job_action.apply_async(
                args=[project, 'cancel', job.id, request.user.email],
                routing_key='publish_to_pulse'
            )

        # Mark pending jobs as cancelled to work around buildbot not including
        # cancelled jobs in builds-4hr if they never started running.
        # TODO: Remove when we stop using buildbot.
        Job.objects.filter(push_id=pk, state='pending').update(
            state='completed',
            result='usercancel',
            last_modified=datetime.datetime.now())

        return Response({"message": "pending and running jobs canceled for resultset '{0}'".format(pk)})
Beispiel #2
0
    def cancel_all(self, request, project, pk=None):
        """
        Cancel all pending and running jobs in this resultset
        """
        if not pk:  # pragma nocover
            return Response({"message": "resultset id required"},
                            status=HTTP_400_BAD_REQUEST)

        # Sending 'cancel_all' action to pulse. Right now there is no listener
        # for this, so we cannot remove 'cancel' action for each job below.
        publish_resultset_action.apply_async(
            args=[project, 'cancel_all', pk, request.user.email],
            routing_key='publish_to_pulse')

        # Notify the build systems which created these jobs...
        for job in Job.objects.filter(push_id=pk).exclude(state='completed'):
            publish_job_action.apply_async(
                args=[project, 'cancel', job.id, request.user.email],
                routing_key='publish_to_pulse')

        # Mark pending jobs as cancelled to work around buildbot not including
        # cancelled jobs in builds-4hr if they never started running.
        # TODO: Remove when we stop using buildbot.
        Job.objects.filter(push_id=pk, state='pending').update(
            state='completed',
            result='usercancel',
            last_modified=datetime.datetime.now())

        return Response({
            "message":
            "pending and running jobs canceled for resultset '{0}'".format(pk)
        })
Beispiel #3
0
    def _job_action_event(self, job, action, requester_email):
        """
        Helper for issuing an 'action' for a given job (such as
        cancel/retrigger)

        :param job int: The job which this action pertains to.
        :param action str: Name of the action (cancel, etc..).
        :param requester str: Email address of the user who caused action.
        """
        publish_job_action.apply_async(
            args=[job.repository.name, action, job.id, requester_email],
            routing_key='publish_to_pulse')
Beispiel #4
0
    def _job_action_event(self, job, action, requester_email):
        """
        Helper for issuing an 'action' for a given job (such as
        cancel/retrigger)

        :param job int: The job which this action pertains to.
        :param action str: Name of the action (cancel, etc..).
        :param requester str: Email address of the user who caused action.
        """
        publish_job_action.apply_async(
            args=[job.repository.name, action, job.id, requester_email],
            routing_key='publish_to_pulse'
        )
Beispiel #5
0
    def _job_action_event(self, job, action, requester):
        """
        Helper for issuing an 'action' for a given job (such as
        cancel/retrigger)

        :param job dict: The job which this action was issued to.
        :param action str: Name of the action (cancel, etc..).
        :param requester str: Email address of the user who caused action.
        """
        publish_job_action.apply_async(
            args=[self.project, action, job['id'], requester],
            routing_key='publish_to_pulse'
        )