Browse code

added node ip autodetection

Manager now auto-detects the address that an agent connects to the cluster
from and stores it. This is useful for many kinds of internal cluster
management tools.

Signed-off-by: Drew Erny <drew.erny@docker.com>

Drew Erny authored on 2016/10/25 08:11:25
Showing 6 changed files
... ...
@@ -77,6 +77,7 @@ type PluginDescription struct {
77 77
 type NodeStatus struct {
78 78
 	State   NodeState `json:",omitempty"`
79 79
 	Message string    `json:",omitempty"`
80
+	Addr    string    `json:",omitempty"`
80 81
 }
81 82
 
82 83
 // Reachability represents the reachability of a node.
... ...
@@ -95,6 +95,7 @@ func printNode(out io.Writer, node swarm.Node) {
95 95
 	fmt.Fprintf(out, " State:\t\t\t%s\n", command.PrettyPrint(node.Status.State))
96 96
 	ioutils.FprintfIfNotEmpty(out, " Message:\t\t%s\n", command.PrettyPrint(node.Status.Message))
97 97
 	fmt.Fprintf(out, " Availability:\t\t%s\n", command.PrettyPrint(node.Spec.Availability))
98
+	ioutils.FprintfIfNotEmpty(out, " Address:\t\t%s\n", command.PrettyPrint(node.Status.Addr))
98 99
 
99 100
 	if node.ManagerStatus != nil {
100 101
 		fmt.Fprintln(out, "Manager Status:")
... ...
@@ -20,6 +20,7 @@ func NodeFromGRPC(n swarmapi.Node) types.Node {
20 20
 		Status: types.NodeStatus{
21 21
 			State:   types.NodeState(strings.ToLower(n.Status.State.String())),
22 22
 			Message: n.Status.Message,
23
+			Addr:    n.Status.Addr,
23 24
 		},
24 25
 	}
25 26
 
... ...
@@ -163,6 +163,7 @@ This section lists each version from latest to oldest.  Each listing includes a
163 163
 * Every API response now includes a `Docker-Experimental` header specifying if experimental features are enabled (value can be `true` or `false`).
164 164
 * 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.
165 165
 * The `SecurityOptions` field within the `GET /info` response now includes `userns` if user namespaces are enabled in the daemon.
166
+* `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.
166 167
 
167 168
 ### v1.24 API changes
168 169
 
... ...
@@ -4464,7 +4464,8 @@ List nodes
4464 4464
           }
4465 4465
         },
4466 4466
         "Status": {
4467
-          "State": "ready"
4467
+          "State": "ready",
4468
+          "Addr": "172.17.0.2"
4468 4469
         },
4469 4470
         "ManagerStatus": {
4470 4471
           "Leader": true,
... ...
@@ -4555,7 +4556,8 @@ Return low-level information on the node `id`
4555 4555
         }
4556 4556
       },
4557 4557
       "Status": {
4558
-        "State": "ready"
4558
+        "State": "ready",
4559
+        "Addr": "172.17.0.2"
4559 4560
       },
4560 4561
       "ManagerStatus": {
4561 4562
         "Leader": true,
... ...
@@ -88,7 +88,8 @@ Example output:
88 88
             }
89 89
         },
90 90
         "Status": {
91
-            "State": "ready"
91
+            "State": "ready",
92
+            "Addr": "168.0.32.137"
92 93
         },
93 94
         "ManagerStatus": {
94 95
             "Leader": true,
... ...
@@ -110,6 +111,7 @@ Example output:
110 110
     Status:
111 111
      State:                 Ready
112 112
      Availability:          Active
113
+     Address:               172.17.0.2
113 114
     Manager Status:
114 115
      Address:               172.17.0.2:2377
115 116
      Raft Status:           Reachable