Skip to content

Commit

Permalink
vendor: update swarmkit to 6478bc1
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Jul 8, 2016
1 parent db43556 commit 4d12e64
Show file tree
Hide file tree
Showing 19 changed files with 1,057 additions and 442 deletions.
2 changes: 1 addition & 1 deletion hack/vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ clone git github.com/docker/docker-credential-helpers v0.3.0
clone git github.com/docker/containerd 1b3a81545ca79456086dc2aa424357be98b962ee

# cluster
clone git github.com/docker/swarmkit 16fa595d3b6fec012830179dc8e9b2d90335527d
clone git github.com/docker/swarmkit 6478bc19cf4bc1d7ba2d6f04ccaacf099508f4a0
clone git github.com/golang/mock bd3c8e81be01eef76d4b503f5e687d2d1354d2d9
clone git github.com/gogo/protobuf 43a2e0b1c32252bfbbdf81f7faa7a88fb3fa4028
clone git github.com/cloudflare/cfssl b895b0549c0ff676f92cf09ba971ae02bb41367b
Expand Down
5 changes: 5 additions & 0 deletions vendor/src/github.com/docker/swarmkit/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ func (a *Agent) run(ctx context.Context) {
sessionq = nil
// if we're here before <-registered, do nothing for that event
registered = nil

// Bounce the connection.
if a.config.Picker != nil {
a.config.Picker.Reset()
}
case <-session.closed:
log.G(ctx).Debugf("agent: rebuild session")

Expand Down
8 changes: 7 additions & 1 deletion vendor/src/github.com/docker/swarmkit/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ type Config struct {
// updated with managers weights as observed by the agent.
Managers picker.Remotes

// Conn specifies the client connection Agent will use
// Conn specifies the client connection Agent will use.
Conn *grpc.ClientConn

// Picker is the picker used by Conn.
// TODO(aaronl): This is only part of the config to allow resetting the
// GRPC connection. This should be refactored to address the coupling
// between Conn and Picker.
Picker *picker.Picker

// Executor specifies the executor to use for the agent.
Executor exec.Executor

Expand Down
4 changes: 3 additions & 1 deletion vendor/src/github.com/docker/swarmkit/agent/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,9 @@ func (n *Node) runAgent(ctx context.Context, db *bolt.DB, creds credentials.Tran
if ctx.Err() != nil {
return ctx.Err()
}
picker := picker.NewPicker(n.remotes, manager.Addr)
conn, err := grpc.Dial(manager.Addr,
grpc.WithPicker(picker.NewPicker(n.remotes, manager.Addr)),
grpc.WithPicker(picker),
grpc.WithTransportCredentials(creds),
grpc.WithBackoffMaxDelay(maxSessionFailureBackoff))
if err != nil {
Expand All @@ -389,6 +390,7 @@ func (n *Node) runAgent(ctx context.Context, db *bolt.DB, creds credentials.Tran
Executor: n.config.Executor,
DB: db,
Conn: conn,
Picker: picker,
NotifyRoleChange: n.roleChangeReq,
})
if err != nil {
Expand Down
47 changes: 37 additions & 10 deletions vendor/src/github.com/docker/swarmkit/agent/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"google.golang.org/grpc/codes"
)

const dispatcherRPCTimeout = 5 * time.Second

var (
errSessionDisconnect = errors.New("agent: session disconnect") // instructed to disconnect
errSessionClosed = errors.New("agent: session closed")
Expand Down Expand Up @@ -88,16 +90,39 @@ func (s *session) start(ctx context.Context) error {
description.Hostname = s.agent.config.Hostname
}

stream, err := client.Session(ctx, &api.SessionRequest{
Description: description,
})
if err != nil {
return err
}
errChan := make(chan error, 1)
var (
msg *api.SessionMessage
stream api.Dispatcher_SessionClient
)
// Note: we don't defer cancellation of this context, because the
// streaming RPC is used after this function returned. We only cancel
// it in the timeout case to make sure the goroutine completes.
sessionCtx, cancelSession := context.WithCancel(ctx)

// Need to run Session in a goroutine since there's no way to set a
// timeout for an individual Recv call in a stream.
go func() {
stream, err = client.Session(sessionCtx, &api.SessionRequest{
Description: description,
})
if err != nil {
errChan <- err
return
}

msg, err := stream.Recv()
if err != nil {
return err
msg, err = stream.Recv()
errChan <- err
}()

select {
case err := <-errChan:
if err != nil {
return err
}
case <-time.After(dispatcherRPCTimeout):
cancelSession()
return errors.New("session initiation timed out")
}

s.sessionID = msg.SessionID
Expand All @@ -115,9 +140,11 @@ func (s *session) heartbeat(ctx context.Context) error {
for {
select {
case <-heartbeat.C:
resp, err := client.Heartbeat(ctx, &api.HeartbeatRequest{
heartbeatCtx, cancel := context.WithTimeout(ctx, dispatcherRPCTimeout)
resp, err := client.Heartbeat(heartbeatCtx, &api.HeartbeatRequest{
SessionID: s.sessionID,
})
cancel()
if err != nil {
if grpc.Code(err) == codes.NotFound {
err = errNodeNotRegistered
Expand Down

0 comments on commit 4d12e64

Please sign in to comment.