-
Notifications
You must be signed in to change notification settings - Fork 132
/
util.go
74 lines (66 loc) · 1.74 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package job
import (
"fmt"
v1 "k8s.io/api/core/v1"
"github.com/armadaproject/armada/internal/executor/configuration"
util2 "github.com/armadaproject/armada/internal/executor/util"
"github.com/armadaproject/armada/pkg/armadaevents"
"github.com/armadaproject/armada/pkg/executorapi"
)
func CreateSubmitJobFromExecutorApiJobRunLease(
jobRunLease *executorapi.JobRunLease,
podDefaults *configuration.PodDefaults,
) (*SubmitJob, error) {
pod, err := util2.CreatePodFromExecutorApiJob(jobRunLease, podDefaults)
if err != nil {
return nil, err
}
jobId, err := armadaevents.UlidStringFromProtoUuid(jobRunLease.Job.JobId)
if err != nil {
return nil, err
}
runId, err := armadaevents.UuidStringFromProtoUuid(jobRunLease.JobRunId)
if err != nil {
return nil, err
}
runMeta := &RunMeta{
JobId: jobId,
RunId: runId,
JobSet: jobRunLease.Jobset,
Queue: jobRunLease.Queue,
}
return &SubmitJob{
Meta: SubmitJobMeta{
RunMeta: runMeta,
Owner: jobRunLease.User,
OwnershipGroups: jobRunLease.Groups,
},
Pod: pod,
Ingresses: util2.ExtractIngresses(jobRunLease, pod, podDefaults.Ingress),
Services: util2.ExtractServices(jobRunLease, pod),
}, nil
}
func ExtractJobRunMeta(pod *v1.Pod) (*RunMeta, error) {
runId := util2.ExtractJobRunId(pod)
if runId == "" {
return nil, fmt.Errorf("job run id is missing")
}
jobId := util2.ExtractJobId(pod)
if jobId == "" {
return nil, fmt.Errorf("job id is missing")
}
queue := util2.ExtractQueue(pod)
if queue == "" {
return nil, fmt.Errorf("queue is missing")
}
jobSet := util2.ExtractJobSet(pod)
if jobSet == "" {
return nil, fmt.Errorf("job set is missing")
}
return &RunMeta{
RunId: runId,
JobId: jobId,
JobSet: jobSet,
Queue: queue,
}, nil
}