Skip to content

Commit

Permalink
Bug Fix: erroneous code block (flyteorg#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
kumare3 authored Aug 29, 2021
1 parent f8b7007 commit 2e8a22b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/tasks/pluginmachinery/flytek8s/pod_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func ConvertPodFailureToError(status v1.PodStatus) (code, message string) {
containerState = c.State
}
if containerState.Terminated != nil {
if strings.Contains(c.State.Terminated.Reason, OOMKilled) {
if strings.Contains(containerState.Terminated.Reason, OOMKilled) {
code = OOMKilled
} else if containerState.Terminated.ExitCode == SIGKILL {
// in some setups, node termination sends SIGKILL to all the containers running on that node. Capturing and
Expand Down
32 changes: 32 additions & 0 deletions go/tasks/pluginmachinery/flytek8s/pod_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,38 @@ func TestConvertPodFailureToError(t *testing.T) {
})
assert.Equal(t, code, "OOMKilled")
})

t.Run("OOMKilled", func(t *testing.T) {
code, _ := ConvertPodFailureToError(v1.PodStatus{
ContainerStatuses: []v1.ContainerStatus{
{
LastTerminationState: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
Reason: OOMKilled,
ExitCode: 137,
},
},
},
},
})
assert.Equal(t, code, "OOMKilled")
})

t.Run("SIGKILL", func(t *testing.T) {
code, _ := ConvertPodFailureToError(v1.PodStatus{
ContainerStatuses: []v1.ContainerStatus{
{
LastTerminationState: v1.ContainerState{
Terminated: &v1.ContainerStateTerminated{
Reason: "some reason",
ExitCode: SIGKILL,
},
},
},
},
})
assert.Equal(t, code, "Interrupted")
})
}

func TestDemystifyPending_testcases(t *testing.T) {
Expand Down

0 comments on commit 2e8a22b

Please sign in to comment.