@@ -59,6 +59,8 @@ const (
59
59
masterPriority = "master-pri"
60
60
defaultNginxImage = "nginx:1.14"
61
61
defaultBusyBoxImage = "busybox:1.24"
62
+ //TODO: Use volcano repo instead in the future
63
+ defaultMPIImage = "tommylike/volcano-example-mpi:0.0.1"
62
64
)
63
65
64
66
func cpuResource (request string ) v1.ResourceList {
@@ -279,6 +281,7 @@ type taskSpec struct {
279
281
min , rep int32
280
282
img string
281
283
command string
284
+ workingDir string
282
285
hostport int32
283
286
req v1.ResourceList
284
287
affinity * v1.Affinity
@@ -359,7 +362,7 @@ func createJobInner(context *context, jobSpec *jobSpec) (*vkv1.Job, error) {
359
362
Spec : v1.PodSpec {
360
363
SchedulerName : "kube-batch" ,
361
364
RestartPolicy : restartPolicy ,
362
- Containers : createContainers (task .img , task .command , task .req , task .hostport ),
365
+ Containers : createContainers (task .img , task .command , task .workingDir , task . req , task .hostport ),
363
366
Affinity : task .affinity ,
364
367
},
365
368
},
@@ -553,7 +556,8 @@ func waitJobUnschedulable(ctx *context, job *vkv1.Job) error {
553
556
return wait .Poll (10 * time .Second , oneMinute , jobUnschedulable (ctx , job , now ))
554
557
}
555
558
556
- func createContainers (img , command string , req v1.ResourceList , hostport int32 ) []v1.Container {
559
+ func createContainers (img , command , workingDir string , req v1.ResourceList , hostport int32 ) []v1.Container {
560
+ var imageRepo []string
557
561
container := v1.Container {
558
562
Image : img ,
559
563
ImagePullPolicy : v1 .PullIfNotPresent ,
@@ -562,10 +566,11 @@ func createContainers(img, command string, req v1.ResourceList, hostport int32)
562
566
},
563
567
}
564
568
if strings .Index (img , ":" ) < 0 {
565
- container . Name = img
569
+ imageRepo = strings . Split ( img , "/" )
566
570
} else {
567
- container . Name = img [:strings .Index (img , ":" )]
571
+ imageRepo = strings . Split ( img [:strings .Index (img , ":" )], "/" )
568
572
}
573
+ container .Name = imageRepo [len (imageRepo )- 1 ]
569
574
570
575
if len (command ) > 0 {
571
576
container .Command = []string {"/bin/sh" }
@@ -581,6 +586,10 @@ func createContainers(img, command string, req v1.ResourceList, hostport int32)
581
586
}
582
587
}
583
588
589
+ if len (workingDir ) > 0 {
590
+ container .WorkingDir = workingDir
591
+ }
592
+
584
593
return []v1.Container {container }
585
594
}
586
595
0 commit comments