zhuqi-lucas commented on code in PR #730:
URL: https://github.com/apache/yunikorn-k8shim/pull/730#discussion_r1501327705
##########
pkg/cache/application.go:
##########
@@ -320,6 +320,10 @@ func (app *Application) getNonTerminatedTaskAlias()
[]string {
return nonTerminatedTaskAlias
}
+func (app *Application) IsAllTasksTerminated() bool {
Review Comment:
Addressed in latest PR, thanks @pbacsko for review.
##########
pkg/shim/scheduler.go:
##########
@@ -158,6 +158,25 @@ func (ss *KubernetesShim) registerShimLayer() error {
func (ss *KubernetesShim) schedule() {
apps := ss.context.GetAllApplications()
for _, app := range apps {
+ // Clean up terminal failed apps for shim side
+ // 1. When we reject an app, we set the app state to Rejected,
and immediately set it to Failed, but we don't clean up the app.
+ // 2. When we failed an app, we set the app state to Failed,
but we don't clean up the app.
+ // 3. The completed app already handled by UpdateApplication
function.
+ // case cache.ApplicationStates().Completed:
+ //
callback.context.RemoveApplicationInternal(updated.ApplicationID)
+ // 4. The killed status is not used until now, so we don't need
to handle it.
Review Comment:
Addressed in latest PR, thanks @pbacsko for review.
##########
pkg/shim/scheduler.go:
##########
@@ -158,6 +158,25 @@ func (ss *KubernetesShim) registerShimLayer() error {
func (ss *KubernetesShim) schedule() {
apps := ss.context.GetAllApplications()
for _, app := range apps {
+ // Clean up terminal failed apps for shim side
+ // 1. When we reject an app, we set the app state to Rejected,
and immediately set it to Failed, but we don't clean up the app.
+ // 2. When we failed an app, we set the app state to Failed,
but we don't clean up the app.
+ // 3. The completed app already handled by UpdateApplication
function.
+ // case cache.ApplicationStates().Completed:
+ //
callback.context.RemoveApplicationInternal(updated.ApplicationID)
+ // 4. The killed status is not used until now, so we don't need
to handle it.
+ if app.GetApplicationState() ==
cache.ApplicationStates().Failed {
+ if app.IsAllTasksTerminated() {
+ log.Log(log.ShimScheduler).Info("Clean up
failed application",
+ zap.String("appID",
app.GetApplicationID()))
+
ss.context.RemoveApplicationInternal(app.GetApplicationID())
+ } else {
+ log.Log(log.ShimScheduler).Info("Failed
application is not cleaned up due to not all tasks terminated, wait for next
scheduling iteration",
+ zap.String("appID",
app.GetApplicationID()))
Review Comment:
Addressed in latest PR, thanks @pbacsko for review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]