mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Ensure that k8s job ids are unique
This commit is contained in:
@@ -226,7 +226,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
|
||||
(see pod selector) and an appropriate restart policy."""
|
||||
k8s_spec_template = {
|
||||
"metadata": {
|
||||
"labels": {"app": self.__produce_unique_k8s_job_name(ajs.job_wrapper.get_id_tag())}
|
||||
"labels": {"app": self.__produce_unique_k8s_job_name(ajs.job_wrapper.get_id_tag())[:-5]}
|
||||
},
|
||||
"spec": {
|
||||
"volumes": self.runner_params['k8s_mountable_volumes'],
|
||||
@@ -526,7 +526,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
|
||||
"""Attempts to delete a dispatched job to the k8s cluster"""
|
||||
job = job_wrapper.get_job()
|
||||
try:
|
||||
name = self.__produce_unique_k8s_job_name(job.get_id_tag())
|
||||
name = job.job_runner_external_id
|
||||
namespace = self.runner_params['k8s_namespace']
|
||||
job_to_delete = find_job_object_by_name(self._pykube_api, name, namespace)
|
||||
if job_to_delete:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Interface layer for pykube library shared between Galaxy and Pulsar."""
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import uuid
|
||||
|
||||
try:
|
||||
@@ -57,7 +59,9 @@ def produce_unique_k8s_job_name(app_prefix=None, instance_id=None, job_id=None):
|
||||
if instance_id and len(instance_id) > 0:
|
||||
job_name += "%s-" % instance_id
|
||||
|
||||
return job_name + job_id
|
||||
unique_id = ''.join(random.choices(string.ascii_lowercase, k=4))
|
||||
|
||||
return job_name + job_id + "-" + unique_id
|
||||
|
||||
|
||||
def pull_policy(params):
|
||||
|
||||
Reference in New Issue
Block a user