Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit c499a48

Browse files
authored
Improve demystifying GKE spot node preemtion #patch (#354)
* Improve demystifying GKE spot node preemtion Signed-off-by: Bernhard Stadlbauer <[email protected]> * Add test Signed-off-by: Bernhard Stadlbauer <[email protected]> --------- Signed-off-by: Bernhard Stadlbauer <[email protected]>
1 parent 8a2f8ca commit c499a48

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

go/tasks/pluginmachinery/flytek8s/pod_helper.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,9 @@ func DemystifyFailure(status v1.PodStatus, info pluginsCore.TaskInfo) (pluginsCo
622622
// startTime: "2022-01-30T14:24:07Z"
623623
// }
624624
// }
625-
if code == "Shutdown" {
625+
//
626+
// In some versions of GKE the reason can also be "Terminated"
627+
if code == "Shutdown" || code == "Terminated" {
626628
return pluginsCore.PhaseInfoSystemRetryableFailure(Interrupted, message, &info), nil
627629
}
628630

go/tasks/pluginmachinery/flytek8s/pod_helper_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,17 @@ func TestDemystifyFailure(t *testing.T) {
900900
assert.Equal(t, "Interrupted", phaseInfo.Err().Code)
901901
assert.Equal(t, core.ExecutionError_SYSTEM, phaseInfo.Err().Kind)
902902
})
903+
904+
t.Run("GKE kubelet graceful node shutdown", func(t *testing.T) {
905+
phaseInfo, err := DemystifyFailure(v1.PodStatus{
906+
Message: "Foobar",
907+
Reason: "Terminated",
908+
}, pluginsCore.TaskInfo{})
909+
assert.Nil(t, err)
910+
assert.Equal(t, pluginsCore.PhaseRetryableFailure, phaseInfo.Phase())
911+
assert.Equal(t, "Interrupted", phaseInfo.Err().Code)
912+
assert.Equal(t, core.ExecutionError_SYSTEM, phaseInfo.Err().Kind)
913+
})
903914
}
904915

905916
func TestDemystifyPending_testcases(t *testing.T) {

0 commit comments

Comments
 (0)