Skip to content

Commit

Permalink
[YUNIKORN-2738] Only check failure reason once when failing app (#877)
Browse files Browse the repository at this point in the history
Optimisation in failure type determination by moving it outside the
loop.

Closes: #877

Signed-off-by: Wilfred Spiegelenburg <[email protected]>
  • Loading branch information
wilfred-s committed Jul 12, 2024
1 parent 4b19450 commit c6f69b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/cache/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,14 @@ func (app *Application) handleFailApplicationEvent(errMsg string) {
unalloc = append(unalloc, app.getTasks(TaskStates().Pending)...)
unalloc = append(unalloc, app.getTasks(TaskStates().Scheduling)...)

timeout := strings.Contains(errMsg, constants.ApplicationInsufficientResourcesFailure)
rejected := strings.Contains(errMsg, constants.ApplicationRejectedFailure)
// publish pod level event to unallocated pods
for _, task := range unalloc {
// Only need to fail the non-placeholder pod(s)
if strings.Contains(errMsg, constants.ApplicationInsufficientResourcesFailure) {
if timeout {
failTaskPodWithReasonAndMsg(task, constants.ApplicationInsufficientResourcesFailure, "Scheduling has timed out due to insufficient resources")
} else if strings.Contains(errMsg, constants.ApplicationRejectedFailure) {
} else if rejected {
errMsgArr := strings.Split(errMsg, ":")
failTaskPodWithReasonAndMsg(task, constants.ApplicationRejectedFailure, errMsgArr[1])
}
Expand Down

0 comments on commit c6f69b7

Please sign in to comment.