Forráskód Böngészése

allow node update api receive node name and id prefix

Signed-off-by: allencloud <allen.sun@daocloud.io>
allencloud 8 éve
szülő
commit
d075b83dd6

+ 7 - 2
daemon/cluster/cluster.go

@@ -1369,7 +1369,7 @@ func (c *Cluster) GetNode(input string) (types.Node, error) {
 }
 }
 
 
 // UpdateNode updates existing nodes properties.
 // UpdateNode updates existing nodes properties.
-func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec) error {
+func (c *Cluster) UpdateNode(input string, version uint64, spec types.NodeSpec) error {
 	c.RLock()
 	c.RLock()
 	defer c.RUnlock()
 	defer c.RUnlock()
 
 
@@ -1385,10 +1385,15 @@ func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec)
 	ctx, cancel := c.getRequestContext()
 	ctx, cancel := c.getRequestContext()
 	defer cancel()
 	defer cancel()
 
 
+	currentNode, err := getNode(ctx, c.client, input)
+	if err != nil {
+		return err
+	}
+
 	_, err = c.client.UpdateNode(
 	_, err = c.client.UpdateNode(
 		ctx,
 		ctx,
 		&swarmapi.UpdateNodeRequest{
 		&swarmapi.UpdateNodeRequest{
-			NodeID: nodeID,
+			NodeID: currentNode.ID,
 			Spec:   &nodeSpec,
 			Spec:   &nodeSpec,
 			NodeVersion: &swarmapi.Version{
 			NodeVersion: &swarmapi.Version{
 				Index: version,
 				Index: version,

+ 1 - 0
docs/reference/api/docker_remote_api.md

@@ -193,6 +193,7 @@ This section lists each version from latest to oldest.  Each listing includes a
 * `POST /plugins/(plugin name)/push` push a plugin.
 * `POST /plugins/(plugin name)/push` push a plugin.
 * `POST /plugins/create?name=(plugin name)` create a plugin.
 * `POST /plugins/create?name=(plugin name)` create a plugin.
 * `DELETE /plugins/(plugin name)` delete a plugin.
 * `DELETE /plugins/(plugin name)` delete a plugin.
+* `POST /node/(id or name)/update` now accepts both `id` or `name` to identify the node to update.
 
 
 
 
 ### v1.24 API changes
 ### v1.24 API changes

+ 4 - 4
docs/reference/api/docker_remote_api_v1.24.md

@@ -3965,7 +3965,7 @@ List nodes
 ### Inspect a node
 ### Inspect a node
 
 
 
 
-`GET /nodes/<id>`
+`GET /nodes/(id or name)`
 
 
 Return low-level information on the node `id`
 Return low-level information on the node `id`
 
 
@@ -4047,9 +4047,9 @@ Return low-level information on the node `id`
 ### Remove a node
 ### Remove a node
 
 
 
 
-`DELETE /nodes/(id)`
+`DELETE /nodes/(id or name)`
 
 
-Remove a node [`id`] from the swarm.
+Remove a node from the swarm.
 
 
 **Example request**:
 **Example request**:
 
 
@@ -4077,7 +4077,7 @@ Remove a node [`id`] from the swarm.
 
 
 `POST /nodes/(id)/update`
 `POST /nodes/(id)/update`
 
 
-Update the node `id`.
+Update a node.
 
 
 The payload of the `POST` request is the new `NodeSpec` and
 The payload of the `POST` request is the new `NodeSpec` and
 overrides the current `NodeSpec` for the specified node.
 overrides the current `NodeSpec` for the specified node.

+ 5 - 5
docs/reference/api/docker_remote_api_v1.25.md

@@ -4564,7 +4564,7 @@ List nodes
 ### Inspect a node
 ### Inspect a node
 
 
 
 
-`GET /nodes/<id>`
+`GET /nodes/(id or name)`
 
 
 Return low-level information on the node `id`
 Return low-level information on the node `id`
 
 
@@ -4647,9 +4647,9 @@ Return low-level information on the node `id`
 ### Remove a node
 ### Remove a node
 
 
 
 
-`DELETE /nodes/(id)`
+`DELETE /nodes/(id or name)`
 
 
-Remove a node [`id`] from the swarm.
+Remove a node from the swarm.
 
 
 **Example request**:
 **Example request**:
 
 
@@ -4675,9 +4675,9 @@ Remove a node [`id`] from the swarm.
 ### Update a node
 ### Update a node
 
 
 
 
-`POST /nodes/(id)/update`
+`POST /nodes/(id or name)/update`
 
 
-Update the node `id`.
+Update a node.
 
 
 The payload of the `POST` request is the new `NodeSpec` and
 The payload of the `POST` request is the new `NodeSpec` and
 overrides the current `NodeSpec` for the specified node.
 overrides the current `NodeSpec` for the specified node.