Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2668 from wsong/fix_node_ids
Browse files Browse the repository at this point in the history
Use engine ID + addr instead of Swarm mode ID for engine IDs
  • Loading branch information
nishanttotla committed Apr 3, 2017
2 parents 2774b07 + 40ff0d9 commit a92b8f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions cluster/engine.go
Expand Up @@ -496,15 +496,11 @@ func (e *Engine) updateSpecs() error {
// Swarm/docker identifies engine by ID. Updating ID but not updating cluster
// index will put the cluster into inconsistent state. If this happens, the
// engine should be put to pending state for re-validation.
var infoID string
if info.Swarm.NodeID != "" {
// Use the swarm-mode node ID if it's available, since it's
// guaranteed to be unique, even if the daemon has a copied
// /etc/docker/key.json file from another machine.
infoID = info.Swarm.NodeID
} else {
infoID = info.ID
}
// We concatenate the engine ID and the address because sometimes engine
// IDs can be duplicated on different nodes (e.g. if a user has
// accidentally copied their /etc/docker/daemon.json file onto another
// node).
infoID := info.ID + "|" + e.Addr
if e.ID == "" {
e.ID = infoID
} else if e.ID != infoID {
Expand Down
6 changes: 3 additions & 3 deletions cluster/swarm/cluster_test.go
Expand Up @@ -55,7 +55,7 @@ var (
func createEngine(t *testing.T, ID string, containers ...*cluster.Container) *cluster.Engine {
engine := cluster.NewEngine(ID, 0, engOpts)
engine.Name = ID
engine.ID = ID
engine.ID = ID + "|" + engine.Addr

for _, container := range containers {
container.Engine = engine
Expand Down Expand Up @@ -133,7 +133,7 @@ func TestImportImage(t *testing.T) {
id := "test-engine"
engine := cluster.NewEngine(id, 0, engOpts)
engine.Name = id
engine.ID = id
engine.ID = id + "|" + engine.Addr

// create mock client
client := mockclient.NewMockClient()
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestTagImage(t *testing.T) {
id := "test-engine"
engine := cluster.NewEngine(id, 0, engOpts)
engine.Name = id
engine.ID = id
engine.ID = id + "|" + engine.Addr

// create mock client
client := mockclient.NewMockClient()
Expand Down

0 comments on commit a92b8f8

Please sign in to comment.