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/25 12:54:01 UTC

[GitHub] [incubator-yunikorn-core] kingamarton commented on a change in pull request #223: YUNIKORN-415: Add "queues" REST API to fetch list of queues

kingamarton commented on a change in pull request #223:
URL: https://github.com/apache/incubator-yunikorn-core/pull/223#discussion_r563677898



##########
File path: pkg/webservice/routes.go
##########
@@ -127,6 +127,13 @@ var webRoutes = routes{
 		getContainerHistory,
 	},
 
+	route{
+		"Scheduler",
+		"GET",
+		"/ws/v1/partition/{partition}/queues",
+		getPartitionQueues,

Review comment:
       Now we have two endpoint for retrieving the queue infos. Shouldn't we delete the old one? Or what is the plan, how will the transition to the new API will be done?

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

Review comment:
       Please extend the error message with the missing parameter names. 

##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +523,24 @@ func updateConfiguration(conf string) (string, error) {
 	}
 	return "", fmt.Errorf("config plugin not found")
 }
+
+func getPartitionQueues(w http.ResponseWriter, r *http.Request) {
+	vars := mux.Vars(r)
+	writeHeaders(w)
+	_, partitionExists := vars["partition"]
+	if len(vars) == 0 || !partitionExists {
+		http.Error(w, "Mandatory parameters are missing in URL path. Please check the usage documentation", http.StatusBadRequest)
+		return
+	}
+	var partitionQueuesDAOInfo dao.PartitionQueueDAOInfo
+	var partition = schedulerContext.GetPartition(vars["partition"])
+	if partition != nil {
+		partitionQueuesDAOInfo = partition.GetPartitionQueues()
+	} else {
+		http.Error(w, "partition not found", http.StatusInternalServerError)

Review comment:
       Wouldn't be better to return with BasRequest error in this case as well? If the partition is not found that means that the user entered a wrong partition name.

##########
File path: pkg/webservice/handlers.go
##########
@@ -521,3 +523,24 @@ func updateConfiguration(conf string) (string, error) {
 	}
 	return "", fmt.Errorf("config plugin not found")
 }
+
+func getPartitionQueues(w http.ResponseWriter, r *http.Request) {
+	vars := mux.Vars(r)
+	writeHeaders(w)
+	_, partitionExists := vars["partition"]

Review comment:
       Please save here the partition name instead of ignoring it, so in the line 536 you can directly use it

##########
File path: pkg/webservice/dao/queue_info.go
##########
@@ -31,3 +31,16 @@ type QueueCapacity struct {
 	UsedCapacity    string `json:"usedcapacity"`
 	AbsUsedCapacity string `json:"absusedcapacity"`
 }
+
+type PartitionQueueDAOInfo struct {
+	QueueName          string                  `json:"queuename"`
+	Status             string                  `json:"status"`
+	Partition          string                  `json:"partition"`
+	MaxResource        string                  `json:"maxResource"`
+	GuaranteedResource string                  `json:"guaranteedResource"`
+	AllocatedResource  string                  `json:"allocatedResource"`
+	IsLeaf             bool                    `json:"isLeaf"`
+	IsManaged          bool                    `json:"isManaged"`
+	Parent             string                  `json:"parent"`
+	Children           []PartitionQueueDAOInfo `json:"children"`
+}

Review comment:
       We already have defined a `QueueDAOInfo`, I think we should reuse/modify that one instead of creating a new DAO structure for the Queues.




----------------------------------------------------------------
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