chia7712 commented on code in PR #938:
URL: https://github.com/apache/yunikorn-core/pull/938#discussion_r1709947812
##########
pkg/webservice/handlers.go:
##########
@@ -898,6 +898,56 @@ func getPartitionRules(w http.ResponseWriter, r
*http.Request) {
}
}
+func getQueueApplicationsByState(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")
+ queueName := vars.ByName("queue")
+ appState := strings.ToLower(vars.ByName("state"))
+ status := strings.ToLower(r.URL.Query().Get("status"))
+
+ queueErr := validateQueue(queueName)
+ if queueErr != nil {
+ buildJSONErrorResponse(w, queueErr.Error(),
http.StatusBadRequest)
+ return
+ }
+ partitionContext :=
schedulerContext.GetPartitionWithoutClusterID(partition)
Review Comment:
`schedulerContext.Load().GetPartitionWithoutClusterID(partition)`
##########
pkg/webservice/handlers.go:
##########
@@ -898,6 +898,56 @@ func getPartitionRules(w http.ResponseWriter, r
*http.Request) {
}
}
+func getQueueApplicationsByState(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")
+ queueName := vars.ByName("queue")
+ appState := strings.ToLower(vars.ByName("state"))
+ status := strings.ToLower(r.URL.Query().Get("status"))
+
+ queueErr := validateQueue(queueName)
+ if queueErr != nil {
+ buildJSONErrorResponse(w, queueErr.Error(),
http.StatusBadRequest)
+ return
+ }
+ partitionContext :=
schedulerContext.GetPartitionWithoutClusterID(partition)
+ if partitionContext == nil {
+ buildJSONErrorResponse(w, PartitionDoesNotExists,
http.StatusNotFound)
+ return
+ }
+ queue := partitionContext.GetQueue(queueName)
+ if queue == nil {
+ buildJSONErrorResponse(w, QueueDoesNotExists,
http.StatusNotFound)
+ return
+ }
+ if appState != "active" {
+ buildJSONErrorResponse(w, fmt.Sprintf("The provided state is
invalid: %s", appState), http.StatusBadRequest)
Review Comment:
Could we align the error message? for example: `"Only following application
states are allowed: active"`
##########
pkg/webservice/handlers.go:
##########
@@ -898,6 +898,56 @@ func getPartitionRules(w http.ResponseWriter, r
*http.Request) {
}
}
+func getQueueApplicationsByState(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")
+ queueName := vars.ByName("queue")
+ appState := strings.ToLower(vars.ByName("state"))
+ status := strings.ToLower(r.URL.Query().Get("status"))
+
+ queueErr := validateQueue(queueName)
+ if queueErr != nil {
+ buildJSONErrorResponse(w, queueErr.Error(),
http.StatusBadRequest)
+ return
+ }
+ partitionContext :=
schedulerContext.GetPartitionWithoutClusterID(partition)
+ if partitionContext == nil {
+ buildJSONErrorResponse(w, PartitionDoesNotExists,
http.StatusNotFound)
+ return
+ }
+ queue := partitionContext.GetQueue(queueName)
+ if queue == nil {
+ buildJSONErrorResponse(w, QueueDoesNotExists,
http.StatusNotFound)
+ return
+ }
+ if appState != "active" {
+ buildJSONErrorResponse(w, fmt.Sprintf("The provided state is
invalid: %s", appState), http.StatusBadRequest)
+ return
+ }
+ if status != "" && !allowedAppActiveStatuses[status] {
+ buildJSONErrorResponse(w, fmt.Sprintf("The provided status is
invalid: %s", status), http.StatusBadRequest)
Review Comment:
`buildJSONErrorResponse(w, allowedActiveStatusMsg, http.StatusBadRequest)`
--
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]