pbacsko commented on code in PR #750:
URL: https://github.com/apache/yunikorn-core/pull/750#discussion_r1425105351
##########
pkg/webservice/handlers.go:
##########
@@ -619,6 +625,57 @@ func getQueueApplications(w http.ResponseWriter, r
*http.Request) {
}
}
+func getPartitionApplicationIDsByState(w http.ResponseWriter, r *http.Request)
{
+ writeHeaders(w)
+ vars := httprouter.ParamsFromContext(r.Context())
+ if vars == nil {
+ buildJSONErrorResponse(w, MissingParamsName,
http.StatusBadRequest)
+ return
+ }
+ partition := vars.ByName("partition")
+ appState := vars.ByName("state")
+
+ partitionContext :=
schedulerContext.GetPartitionWithoutClusterID(partition)
+ if partitionContext == nil {
+ buildJSONErrorResponse(w, PartitionDoesNotExists,
http.StatusNotFound)
+ return
+ }
+ if !allowedAppStates[appState] {
+ buildJSONErrorResponse(w, "Application state is not allowed:
"+appState, http.StatusBadRequest)
+ return
+ }
+ appIDs := partitionContext.GetAppIDsByState(appState)
Review Comment:
I've just realized this... A big question here: if we already do state-based
filtering here, do we need to do that again in `GetAppIDsByState()`? We
shouldn't have the same logic in two places, it's not needed. What we expose on
REST is an interface decision, so I'd rather have it here only.
`getAppsByState()` should have an exposed pair `GetAppsByState()` which we call
here.
##########
pkg/scheduler/partition.go:
##########
@@ -1066,6 +1070,18 @@ func (pc *PartitionContext) GetRejectedApplications()
[]*objects.Application {
return appList
}
+func (pc *PartitionContext) GetAppIDsByState(state string) []string {
Review Comment:
See below, I don't think this method needed as is.
##########
pkg/webservice/handlers.go:
##########
@@ -60,6 +60,12 @@ const (
NodeDoesNotExists = "Node not found"
)
+var allowedAppStates = map[string]bool{
Review Comment:
It was discussed upstream w/ Wilfred. We don't want to return all kinds of
states. A comment here would be useful.
--
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]