Tzu-Hua Lan created YUNIKORN-2835:
-------------------------------------
Summary: Refactor switch statement in UpdateApplication
Key: YUNIKORN-2835
URL: https://issues.apache.org/jira/browse/YUNIKORN-2835
Project: Apache YuniKorn
Issue Type: Improvement
Components: shim - kubernetes
Reporter: Tzu-Hua Lan
Assignee: Tzu-Hua Lan
The application state handling code in the UpdateApplication method of
AsyncRMCallback struct (in scheduler_callback.go) could be improved.
The current implementation uses a switch statement with a default case that
actually handles two specific states, which may not align with the typical
expectations for a default case.
Current implementation: [link
title|https://github.com/apache/yunikorn-k8shim/blob/5bb3890580cc9865efc0d5d84f69f897d4775a3a/pkg/cache/scheduler_callback.go#L149-L154]
{code:go}
switch updated.State {
case ApplicationStates().Completed:
// ...
case ApplicationStates().Resuming:
// ...
default:
if updated.State == ApplicationStates().Failing || updated.State ==
ApplicationStates().Failed {
// ...
}
}
{code}
Proposed implementation:
{code:go}
switch updated.State {
case ApplicationStates().Completed:
// ...
case ApplicationStates().Resuming:
// ...
case ApplicationStates().Failing, ApplicationStates().Failed:
// ...
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]