瀏覽代碼

Merge pull request #27910 from dperny/node_ip_in_raft

Auto-detect node IP address
Sebastiaan van Stijn 8 年之前
父節點
當前提交
b2641bd9df

+ 1 - 0
api/types/swarm/node.go

@@ -77,6 +77,7 @@ type PluginDescription struct {
 type NodeStatus struct {
 	State   NodeState `json:",omitempty"`
 	Message string    `json:",omitempty"`
+	Addr    string    `json:",omitempty"`
 }
 
 // Reachability represents the reachability of a node.

+ 1 - 0
cli/command/node/inspect.go

@@ -95,6 +95,7 @@ func printNode(out io.Writer, node swarm.Node) {
 	fmt.Fprintf(out, " State:\t\t\t%s\n", command.PrettyPrint(node.Status.State))
 	ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", command.PrettyPrint(node.Status.Message))
 	fmt.Fprintf(out, " Availability:\t\t%s\n", command.PrettyPrint(node.Spec.Availability))
+	ioutils.FprintfIfNotEmpty(out, " Address:\t\t%s\n", command.PrettyPrint(node.Status.Addr))
 
 	if node.ManagerStatus != nil {
 		fmt.Fprintln(out, "Manager Status:")

+ 1 - 0
daemon/cluster/convert/node.go

@@ -20,6 +20,7 @@ func NodeFromGRPC(n swarmapi.Node) types.Node {
 		Status: types.NodeStatus{
 			State:   types.NodeState(strings.ToLower(n.Status.State.String())),
 			Message: n.Status.Message,
+			Addr:    n.Status.Addr,
 		},
 	}
 

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

@@ -163,6 +163,7 @@ This section lists each version from latest to oldest.  Each listing includes a
 * Every API response now includes a `Docker-Experimental` header specifying if experimental features are enabled (value can be `true` or `false`).
 * The `hostConfig` option now accepts the fields `CpuRealtimePeriod` and `CpuRtRuntime` to allocate cpu runtime to rt tasks when `CONFIG_RT_GROUP_SCHED` is enabled in the kernel.
 * The `SecurityOptions` field within the `GET /info` response now includes `userns` if user namespaces are enabled in the daemon.
+* `GET /nodes` and `GET /node/(id or name)` now return `Addr` as part of a node's `Status`, which is the address that that node connects to the manager from.
 
 ### v1.24 API changes
 

+ 4 - 2
docs/reference/api/docker_remote_api_v1.25.md

@@ -4464,7 +4464,8 @@ List nodes
           }
         },
         "Status": {
-          "State": "ready"
+          "State": "ready",
+          "Addr": "172.17.0.2"
         },
         "ManagerStatus": {
           "Leader": true,
@@ -4555,7 +4556,8 @@ Return low-level information on the node `id`
         }
       },
       "Status": {
-        "State": "ready"
+        "State": "ready",
+        "Addr": "172.17.0.2"
       },
       "ManagerStatus": {
         "Leader": true,

+ 3 - 1
docs/reference/commandline/node_inspect.md

@@ -88,7 +88,8 @@ Example output:
             }
         },
         "Status": {
-            "State": "ready"
+            "State": "ready",
+            "Addr": "168.0.32.137"
         },
         "ManagerStatus": {
             "Leader": true,
@@ -110,6 +111,7 @@ Example output:
     Status:
      State:                 Ready
      Availability:          Active
+     Address:               172.17.0.2
     Manager Status:
      Address:               172.17.0.2:2377
      Raft Status:           Reachable