utility.py 571 Bytes
Newer Older
1
2
3
from datetime import timezone


4
5
def generate_helm_name(process_id, job_name):
    return process_id + '-' + job_name
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


def get_job_info(job):
    """"
    job is a Kubernetes V1Job
    """
    utc_start_time = job.status.start_time
    local_start_time = utc_start_time.replace(tzinfo=timezone.utc).astimezone(tz=None)
    status = 'Unknown'
    if job.status.failed:
        status = 'Failed'
    elif (job.status.active):
        status = 'Running'
    return {
            "status": status,
            "started": local_start_time.strftime("%m/%d/%Y, %H:%M:%S")
    }