kingamarton commented on a change in pull request #260:
URL:
https://github.com/apache/incubator-yunikorn-core/pull/260#discussion_r596917982
##########
File path: pkg/scheduler/objects/application.go
##########
@@ -1303,3 +1281,52 @@ func (sa *Application)
notifyRMAllocationAskReleased(rmID string, released []*Al
}
sa.rmEventHandler.HandleEvent(releaseEvent)
}
+
+func (sa *Application) failAppIfPossible() {
+ if sa.isApplicationEmpty(false) {
+ // we need to run this in a different go routine to avoid
deadlock in sm
+ // nolint: errcheck
+ go sa.HandleApplicationEvent(FailApplication)
+ }
+}
+
+func (sa *Application) isApplicationEmpty(skipPlaceholders bool) bool {
+ if skipPlaceholders {
+ return resources.IsZero(sa.pending) &&
resources.IsZero(sa.allocatedResource)
+ }
+ return resources.IsZero(sa.pending) &&
resources.IsZero(sa.allocatedResource) &&
resources.IsZero(sa.allocatedPlaceholder)
+}
+
+// lock free call, this should be called when holding a lock on the
application object
+func (sa *Application) handleStateChange() {
Review comment:
I made the changes we discussed about.
I also kept the `func (sa *Application) failAppIfPossible()` function,
because I checked the code and when there is a partition removed, we want to
fail the application as well, and in this case we might have no allocations, to
trigger the transition to Failed state.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]