'Attempts to delete a dispatched job to the k8s cluster'

def stop_job(self, job):

    try:
        jobs = Job.objects(self._pykube_api).filter(selector=('app=' + self.__produce_unique_k8s_job_name(job.get_id_tag())))
        if (len(jobs.response['items']) >= 0):
            job_to_delete = Job(self._pykube_api, jobs.response['items'][0])
            job_to_delete.scale(replicas=0)
        log.debug(("(%s/%s)    Terminated    at    user's    request" % (job.id, job.job_runner_external_id)))
    except Exception as e:
        log.debug(('(%s/%s)    User    killed    running    job,    but    error    encountered    during    termination:    %s' % (job.id, job.job_runner_external_id, e)))
