Merge pull request #27631 from allencloud/get-node-brefore-update

allow node update API to receive node name and id prefix
This commit is contained in:
Vincent Demeester 2016-11-16 17:47:31 +01:00 committed by GitHub
commit 673c5ee559
4 changed files with 17 additions and 11 deletions

View file

@ -1375,7 +1375,7 @@ func (c *Cluster) GetNode(input string) (types.Node, error) {
}
// 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()
defer c.RUnlock()
@ -1391,10 +1391,15 @@ func (c *Cluster) UpdateNode(nodeID string, version uint64, spec types.NodeSpec)
ctx, cancel := c.getRequestContext()
defer cancel()
currentNode, err := getNode(ctx, c.client, input)
if err != nil {
return err
}
_, err = c.client.UpdateNode(
ctx,
&swarmapi.UpdateNodeRequest{
NodeID: nodeID,
NodeID: currentNode.ID,
Spec: &nodeSpec,
NodeVersion: &swarmapi.Version{
Index: version,

View file

@ -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/create?name=(plugin name)` create 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

View file

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

View file

@ -4564,7 +4564,7 @@ List nodes
### Inspect a node
`GET /nodes/<id>`
`GET /nodes/(id or name)`
Return low-level information on the node `id`
@ -4647,9 +4647,9 @@ Return low-level information on the node `id`
### 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**:
@ -4675,9 +4675,9 @@ Remove a node [`id`] from the swarm.
### 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
overrides the current `NodeSpec` for the specified node.