You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@yunikorn.apache.org by "Tzu-Hua Lan (Jira)" <ji...@apache.org> on 2024/08/25 13:47:00 UTC
[jira] [Created] (YUNIKORN-2835) Refactor switch statement in UpdateApplication
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: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org