[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Consolidate slice append (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
yqwang-ms committed Jul 17, 2019
1 parent 1fb9e25 commit a4b9eeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions pkg/apis/frameworkcontroller/v1/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,15 @@ func (f *Framework) NewPod(cm *core.ConfigMap, taskRoleName string, taskIndex in
// is failed and the termination message file specified by the terminationMessagePath
// is not found or empty.
for i := range pod.Spec.Containers {
pod.Spec.Containers[i].Env = append(predefinedEnvs, pod.Spec.Containers[i].Env...)
pod.Spec.Containers[i].Env = append(append([]core.EnvVar{},
predefinedEnvs...), pod.Spec.Containers[i].Env...)
if len(pod.Spec.Containers[i].TerminationMessagePolicy) == 0 {
pod.Spec.Containers[i].TerminationMessagePolicy = core.TerminationMessageFallbackToLogsOnError
}
}
for i := range pod.Spec.InitContainers {
pod.Spec.InitContainers[i].Env = append(predefinedEnvs, pod.Spec.InitContainers[i].Env...)
pod.Spec.InitContainers[i].Env = append(append([]core.EnvVar{},
predefinedEnvs...), pod.Spec.InitContainers[i].Env...)
if len(pod.Spec.InitContainers[i].TerminationMessagePolicy) == 0 {
pod.Spec.InitContainers[i].TerminationMessagePolicy = core.TerminationMessageFallbackToLogsOnError
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,8 @@ func (c *FrameworkController) syncTaskState(
} else if pod.Status.Phase == core.PodFailed {
// All Container names in a Pod must be different, so we can still identify
// a Container even after the InitContainers is merged with the AppContainers.
allContainerStatuses := append(
pod.Status.InitContainerStatuses,
allContainerStatuses := append(append([]core.ContainerStatus{},
pod.Status.InitContainerStatuses...),
pod.Status.ContainerStatuses...)

lastContainerExitCode := common.NilInt32()
Expand Down

0 comments on commit a4b9eeb

Please sign in to comment.