You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by "Tzu-Hua Lan (Jira)" <ji...@apache.org> on 2024/08/25 13:49:00 UTC
[jira] [Updated] (YUNIKORN-2835) Refactor switch statement in UpdateApplication
[ https://issues.apache.org/jira/browse/YUNIKORN-2835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tzu-Hua Lan updated YUNIKORN-2835:
----------------------------------
Description:
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|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}
was:
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}
> 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
> Priority: Trivial
>
> 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|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: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org