You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by GitBox <gi...@apache.org> on 2021/01/22 06:45:23 UTC

[GitHub] [incubator-yunikorn-core] yangwwei commented on a change in pull request #224: YUNIKORN-416: Add "applications" REST API to fetch list of applications

yangwwei commented on a change in pull request #224:
URL: https://github.com/apache/incubator-yunikorn-core/pull/224#discussion_r562407705



##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +522,49 @@ func updateConfiguration(conf string) (string, error) {
 	}
 	return "", fmt.Errorf("config plugin not found")
 }
+
+func getQueueApplications(w http.ResponseWriter, r *http.Request) {
+	vars := mux.Vars(r)
+	writeHeaders(w)
+	if len(vars) != 2 {
+		http.Error(w, "Mandatory parameters are missing in URL path. Please check the usage documentation", http.StatusBadRequest)
+		return
+	}
+	var queueName = vars["queue"]
+	if len(queueName) == 0 {
+		http.Error(w, "Queue is missing in URL path. Please check the usage documentation", http.StatusBadRequest)
+		return
+	}
+	queueErr := validateQueue(queueName)
+	if queueErr != nil {
+		http.Error(w, queueErr.Error(), http.StatusBadRequest)
+		return
+	}
+	var partitionExists = false
+	var queueExists = false
+	var appsDao []*dao.ApplicationDAOInfo
+	lists := schedulerContext.GetPartitionMapClone()
+	for _, partition := range lists {
+		if partition.Name == vars["partition"] {
+			partitionExists = true
+			appList := partition.GetApplications()

Review comment:
       This function is supposed to get all applications from a queue, why we need to loop the partition?
   Can we leverage `queue#getCopyOfApps()`?

##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +523,43 @@ func updateConfiguration(conf string) (string, error) {
 	}
 	return "", fmt.Errorf("config plugin not found")
 }
+
+func getQueueApplications(w http.ResponseWriter, r *http.Request) {
+	vars := mux.Vars(r)
+	writeHeaders(w)
+	_, partitionExists := vars["partition"]
+	_, queueExists := vars["queue"]
+	var queueName = vars["queue"]
+
+	if len(vars) != 2 || !partitionExists || !queueExists {
+		http.Error(w, "Mandatory parameters are missing in URL path. Please check the usage documentation", http.StatusBadRequest)

Review comment:
       It is better to explicitly what parameters are missing in the error message, that will be easier for the user to follow. Instead of asking them to look at the docs. 




----------------------------------------------------------------
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:
users@infra.apache.org