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 2020/09/03 12:32:33 UTC

[GitHub] [incubator-yunikorn-core] kingamarton commented on a change in pull request #198: [WIP][YUNIKORN-366] Add rest API to update queue configuration

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



##########
File path: pkg/cache/cluster_info.go
##########
@@ -483,12 +484,33 @@ func (m *ClusterInfo) processRMRegistrationEvent(event *commonevents.RegisterRME
 // Updated and deleted partitions can not fail on the scheduler side.
 // Locking occurs by the methods that are called, this must be lock free.
 func (m *ClusterInfo) processRMConfigUpdateEvent(event *commonevents.ConfigUpdateRMEvent) {
+	if m.skipConfigUpdate {

Review comment:
       removed it

##########
File path: pkg/webservice/handlers.go
##########
@@ -339,3 +341,63 @@ func getClusterConfig(w http.ResponseWriter, r *http.Request) {
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 	}
 }
+
+func updateConfig(w http.ResponseWriter, r *http.Request) {
+	lock.Lock()
+	defer lock.Unlock()
+	writeHeaders(w)
+	requestBytes, err := ioutil.ReadAll(r.Body)
+	if err != nil {
+		buildUpdateResponse(false, err.Error(), w)
+		return
+	}
+	// validation is already called when loading the config
+	schedulerConf, err := configs.LoadSchedulerConfigFromByteArray(requestBytes)
+	if err != nil {
+		buildUpdateResponse(false, err.Error(), w)
+		return
+	}
+	oldConf, err := updateConfiguration(string(requestBytes))
+	if err != nil {
+		buildUpdateResponse(false, err.Error(), w)
+		return
+	}
+	err = gClusterInfo.UpdateSchedulerConfig(schedulerConf)
+	if err != nil {
+		// revert configmap changes
+		_, err := updateConfiguration(oldConf)
+		if err != nil {
+			log.Logger().Error("Configuration rollback failed")
+		}
+		buildUpdateResponse(false, err.Error(), w)
+		return
+	}
+	buildUpdateResponse(true, "", w)
+}
+
+func buildUpdateResponse(success bool, reason string, w http.ResponseWriter) {

Review comment:
       Changed it




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