'Abort executions that have started and are past the job\'s max runtime.'

def _abort_jobs_past_max_runtime(self):

    logging.info('Aborting    all    jobs    that    have    passed    maximum    runtime')
    rows = self._db.execute('\n                                                SELECT    hqe.id\n                                                FROM    afe_host_queue_entries    AS    hqe\n                                                INNER    JOIN    afe_jobs    ON    (hqe.job_id    =    afe_jobs.id)\n                                                WHERE    NOT    hqe.complete    AND    NOT    hqe.aborted    AND\n                                                hqe.started_on    +    INTERVAL    afe_jobs.max_runtime_hrs    HOUR    <    NOW()')
    query = models.HostQueueEntry.objects.filter(id__in=[row[0] for row in rows])
    for queue_entry in query.distinct():
        logging.warning('Aborting    entry    %s    due    to    max    runtime', queue_entry)
        logging.info(('Disabling    installation    on    %s' % queue_entry.host.hostname))
        self._disable_host_installation(queue_entry.host.hostname)
        queue_entry.abort()
