(api spec.API, job *spec.BatchJob)
| 279 | } |
| 280 | |
| 281 | func BatchContainers(api spec.API, job *spec.BatchJob) ([]kcore.Container, []kcore.Volume) { |
| 282 | userContainers, userVolumes := userPodContainers(api) |
| 283 | dequeuerContainer, dequeuerVolume := batchDequeuerProxyContainer(api, job.ID, job.SQSUrl) |
| 284 | |
| 285 | // make sure the dequeuer starts first to allow it to start watching the graveyard before user containers begin |
| 286 | containers := append([]kcore.Container{dequeuerContainer}, userContainers...) |
| 287 | volumes := append([]kcore.Volume{dequeuerVolume}, userVolumes...) |
| 288 | |
| 289 | k8sName := job.K8sName() |
| 290 | |
| 291 | volumes = append(volumes, |
| 292 | KubexitVolume(), |
| 293 | APIConfigVolume(k8sName), |
| 294 | ) |
| 295 | |
| 296 | containerNames := userconfig.GetContainerNames(api.Pod.Containers) |
| 297 | containerNames.Add(dequeuerContainer.Name) |
| 298 | |
| 299 | for i, c := range containers { |
| 300 | containers[i].VolumeMounts = append(containers[i].VolumeMounts, |
| 301 | KubexitMount(), |
| 302 | APIConfigMount(k8sName), |
| 303 | ) |
| 304 | |
| 305 | containerDeathDependencies := containerNames.Copy() |
| 306 | containerDeathDependencies.Remove(c.Name) |
| 307 | containerDeathEnvVars := getKubexitEnvVars(c.Name, containerDeathDependencies.SliceSorted(), nil) |
| 308 | containers[i].Env = append(containers[i].Env, containerDeathEnvVars...) |
| 309 | |
| 310 | if c.Command[0] != "/cortex/kubexit" { |
| 311 | containers[i].Command = append([]string{"/cortex/kubexit"}, c.Command...) |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | return containers, volumes |
| 316 | } |
| 317 | |
| 318 | func userPodContainers(api spec.API) ([]kcore.Container, []kcore.Volume) { |
| 319 | volumes := []kcore.Volume{ |
no test coverage detected