Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package agent

import (
"bytes"
"fmt"
"math/rand"
"reflect"
"sync"
Expand All @@ -11,6 +10,7 @@ import (
"github.com/docker/swarmkit/agent/exec"
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/log"
"github.com/pkg/errors"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -444,7 +444,7 @@ func (a *Agent) handleSessionMessage(ctx context.Context, message *api.SessionMe
if !same {
a.keys = message.NetworkBootstrapKeys
if err := a.config.Executor.SetNetworkBootstrapKeys(a.keys); err != nil {
panic(fmt.Errorf("configuring network key failed"))
return errors.Wrap(err, "configuring network key failed")
Copy link
Copy Markdown
Contributor

@cyli cyli Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this fix, but this logic seems a little odd:

	for _, key := range message.NetworkBootstrapKeys {
		same := false
		for _, agentKey := range a.keys {
			if agentKey.LamportTime == key.LamportTime {
				same = true
			}
		}
		if !same {
			a.keys = message.NetworkBootstrapKeys
			if err := a.config.Executor.SetNetworkBootstrapKeys(a.keys); err != nil {
				return errors.Wrap(err, "configuring network key failed")
			}
		}
	}

It looks like we are looping over each bootstrap key, and for each key that is different, we set the agent keys to the bootstrap keys - so if multiple keys are different, we'd set the same set of keys multiple times.

This seems like an idempotent action, so it's probably not an issue, but it does give the executor more changes to fail.

Happy to change this in a different PR, though.

Copy link
Copy Markdown
Contributor

@cyli cyli Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting the network bootstrap keys an expensive or prone-to-failure operation? Can we just set it every time without checking for whether it's different or the same? cc @abhi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From slack conversation - we're not sure whether it's expensive.

}
}
}
Expand Down