mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Allow partial cluster config updates.
This commit is contained in:
@@ -215,12 +215,27 @@ func (ps *PeerServer) getClusterConfigHttpHandler(w http.ResponseWriter, req *ht
|
|||||||
|
|
||||||
// Updates the cluster configuration.
|
// Updates the cluster configuration.
|
||||||
func (ps *PeerServer) setClusterConfigHttpHandler(w http.ResponseWriter, req *http.Request) {
|
func (ps *PeerServer) setClusterConfigHttpHandler(w http.ResponseWriter, req *http.Request) {
|
||||||
c := &SetClusterConfigCommand{Config: &ClusterConfig{}}
|
// Decode map.
|
||||||
if err := json.NewDecoder(req.Body).Decode(&c.Config); err != nil {
|
m := make(map[string]interface{})
|
||||||
|
if err := json.NewDecoder(req.Body).Decode(&m); err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy config and update fields passed in.
|
||||||
|
config := &ClusterConfig{
|
||||||
|
ActiveSize: ps.clusterConfig.ActiveSize,
|
||||||
|
PromoteDelay: ps.clusterConfig.PromoteDelay,
|
||||||
|
}
|
||||||
|
if activeSize, ok := m["activeSize"].(float64); ok {
|
||||||
|
config.ActiveSize = int(activeSize)
|
||||||
|
}
|
||||||
|
if promoteDelay, ok := m["promoteDelay"].(float64); ok {
|
||||||
|
config.PromoteDelay = int(promoteDelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue command to update.
|
||||||
|
c := &SetClusterConfigCommand{Config: config}
|
||||||
log.Debugf("[recv] Update Cluster Config Request")
|
log.Debugf("[recv] Update Cluster Config Request")
|
||||||
ps.server.Dispatch(c, w, req)
|
ps.server.Dispatch(c, w, req)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user