You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@yunikorn.apache.org by GitBox <gi...@apache.org> on 2020/03/17 04:26:31 UTC

[GitHub] [incubator-yunikorn-core] yangwwei commented on a change in pull request #103: [YUNIKORN-28] Support validating conf via REST API

yangwwei commented on a change in pull request #103: [YUNIKORN-28] Support validating conf via REST API
URL: https://github.com/apache/incubator-yunikorn-core/pull/103#discussion_r393438386
 
 

 ##########
 File path: pkg/webservice/handlers.go
 ##########
 @@ -118,6 +120,24 @@ func GetNodesInfo(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
+func ValidateConf(w http.ResponseWriter, r *http.Request) {
+	writeHeaders(w)
+	requestBytes, err := ioutil.ReadAll(r.Body)
+	if err == nil {
+		_, err = configs.LoadSchedulerConfigFromByteArray(requestBytes)
+	}
+	var result dao.ValidateConfResponse
+	if err != nil {
+		result.Allowed = false
+		result.Error = err.Error()
+	} else {
+		result.Allowed = true
+	}
+	if err := json.NewEncoder(w).Encode(result); err != nil {
+		panic(err)
 
 Review comment:
   Hmmm, we should not have any `panic` here.
   Can we replace all panic to `http.Error()`?

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org