浏览代码

Merge pull request #25154 from aaronlehmann/remove-join-tokens-from-info-master

Remove join-tokens from the /info API
Tibor Vass 9 年之前
父节点
当前提交
58d0d5b6b5

+ 4 - 1
daemon/cluster/cluster.go

@@ -733,7 +733,10 @@ func (c *Cluster) Info() types.Info {
 		if err != nil {
 		if err != nil {
 			info.Error = err.Error()
 			info.Error = err.Error()
 		}
 		}
-		info.Cluster = swarm
+
+		// Strip JoinTokens
+		info.Cluster = swarm.ClusterInfo
+
 		if r, err := c.client.ListNodes(ctx, &swarmapi.ListNodesRequest{}); err == nil {
 		if r, err := c.client.ListNodes(ctx, &swarmapi.ListNodesRequest{}); err == nil {
 			info.Nodes = len(r.Nodes)
 			info.Nodes = len(r.Nodes)
 			for _, n := range r.Nodes {
 			for _, n := range r.Nodes {

+ 13 - 11
daemon/cluster/convert/swarm.go

@@ -13,17 +13,19 @@ import (
 // SwarmFromGRPC converts a grpc Cluster to a Swarm.
 // SwarmFromGRPC converts a grpc Cluster to a Swarm.
 func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
 func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
 	swarm := types.Swarm{
 	swarm := types.Swarm{
-		ID: c.ID,
-		Spec: types.Spec{
-			Orchestration: types.OrchestrationConfig{
-				TaskHistoryRetentionLimit: c.Spec.Orchestration.TaskHistoryRetentionLimit,
-			},
-			Raft: types.RaftConfig{
-				SnapshotInterval:           c.Spec.Raft.SnapshotInterval,
-				KeepOldSnapshots:           c.Spec.Raft.KeepOldSnapshots,
-				LogEntriesForSlowFollowers: c.Spec.Raft.LogEntriesForSlowFollowers,
-				HeartbeatTick:              c.Spec.Raft.HeartbeatTick,
-				ElectionTick:               c.Spec.Raft.ElectionTick,
+		ClusterInfo: types.ClusterInfo{
+			ID: c.ID,
+			Spec: types.Spec{
+				Orchestration: types.OrchestrationConfig{
+					TaskHistoryRetentionLimit: c.Spec.Orchestration.TaskHistoryRetentionLimit,
+				},
+				Raft: types.RaftConfig{
+					SnapshotInterval:           c.Spec.Raft.SnapshotInterval,
+					KeepOldSnapshots:           c.Spec.Raft.KeepOldSnapshots,
+					LogEntriesForSlowFollowers: c.Spec.Raft.LogEntriesForSlowFollowers,
+					HeartbeatTick:              c.Spec.Raft.HeartbeatTick,
+					ElectionTick:               c.Spec.Raft.ElectionTick,
+				},
 			},
 			},
 		},
 		},
 		JoinTokens: types.JoinTokens{
 		JoinTokens: types.JoinTokens{

+ 1 - 1
hack/vendor.sh

@@ -60,7 +60,7 @@ clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://gith
 clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
 clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git
 clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
 clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
 clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d
 clone git github.com/docker/go-connections fa2850ff103453a9ad190da0df0af134f0314b3d
-clone git github.com/docker/engine-api a52656d77f09d394104c1639824eada038bfdb89
+clone git github.com/docker/engine-api 3d1601b9d2436a70b0dfc045a23f6503d19195df
 clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
 clone git github.com/RackSec/srslog 259aed10dfa74ea2961eddd1d9847619f6e98837
 clone git github.com/imdario/mergo 0.2.1
 clone git github.com/imdario/mergo 0.2.1
 
 

+ 10 - 4
vendor/src/github.com/docker/engine-api/types/swarm/swarm.go

@@ -2,11 +2,17 @@ package swarm
 
 
 import "time"
 import "time"
 
 
-// Swarm represents a swarm.
-type Swarm struct {
+// ClusterInfo represents info about a the cluster for outputing in "info"
+// it contains the same information as "Swarm", but without the JoinTokens
+type ClusterInfo struct {
 	ID string
 	ID string
 	Meta
 	Meta
-	Spec       Spec
+	Spec Spec
+}
+
+// Swarm represents a swarm.
+type Swarm struct {
+	ClusterInfo
 	JoinTokens JoinTokens
 	JoinTokens JoinTokens
 }
 }
 
 
@@ -119,7 +125,7 @@ type Info struct {
 	Nodes          int
 	Nodes          int
 	Managers       int
 	Managers       int
 
 
-	Cluster Swarm
+	Cluster ClusterInfo
 }
 }
 
 
 // Peer represents a peer.
 // Peer represents a peer.

+ 4 - 1
vendor/src/github.com/docker/engine-api/types/types.go

@@ -256,7 +256,10 @@ type Info struct {
 	Runtimes           map[string]Runtime
 	Runtimes           map[string]Runtime
 	DefaultRuntime     string
 	DefaultRuntime     string
 	Swarm              swarm.Info
 	Swarm              swarm.Info
-	LiveRestore        bool
+	// LiveRestoreEnabled determines whether containers should be kept
+	// running when the daemon is shutdown or upon daemon start if
+	// running containers are detected
+	LiveRestoreEnabled bool
 }
 }
 
 
 // PluginsInfo is a temp struct holding Plugins name
 // PluginsInfo is a temp struct holding Plugins name