Bump SwarmKit to 8852e8840e30d69db0b39a4a3d6447362e17c64f

Relevant changes;

- swarmkit #2593 agent: return error when failing to apply network key
- swarmkit #2645 Replace deprecated grpc functions
- swarmkit #2720 Test if error is nil before to log it
- swarmkit #2712 [orchestrator] Fix task sorting
- swarmkit #2677 [manager/orchestrator/reaper] Fix the condition used for skipping over running tasks

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-08-03 18:49:44 +02:00
parent 75fe414440
commit 660fa129c0
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
9 changed files with 71 additions and 50 deletions

View file

@ -125,7 +125,7 @@ github.com/containerd/ttrpc 94dde388801693c54f88a6596f713b51a8b30b2d
github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef
# cluster # cluster
github.com/docker/swarmkit 68266392a176434d282760d2d6d0ab4c68edcae6 github.com/docker/swarmkit 8852e8840e30d69db0b39a4a3d6447362e17c64f
github.com/gogo/protobuf v1.0.0 github.com/gogo/protobuf v1.0.0
github.com/cloudflare/cfssl 1.3.2 github.com/cloudflare/cfssl 1.3.2
github.com/fernet/fernet-go 1b2437bc582b3cfbb341ee5a29f8ef5b42912ff2 github.com/fernet/fernet-go 1b2437bc582b3cfbb341ee5a29f8ef5b42912ff2

View file

@ -2,7 +2,6 @@ package agent
import ( import (
"bytes" "bytes"
"fmt"
"math/rand" "math/rand"
"reflect" "reflect"
"sync" "sync"
@ -11,6 +10,7 @@ import (
"github.com/docker/swarmkit/agent/exec" "github.com/docker/swarmkit/agent/exec"
"github.com/docker/swarmkit/api" "github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/log" "github.com/docker/swarmkit/log"
"github.com/pkg/errors"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -444,7 +444,7 @@ func (a *Agent) handleSessionMessage(ctx context.Context, message *api.SessionMe
if !same { if !same {
a.keys = message.NetworkBootstrapKeys a.keys = message.NetworkBootstrapKeys
if err := a.config.Executor.SetNetworkBootstrapKeys(a.keys); err != nil { 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")
} }
} }
} }

View file

@ -12,6 +12,7 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
var ( var (
@ -195,7 +196,8 @@ func (s *session) heartbeat(ctx context.Context) error {
cancel() cancel()
if err != nil { if err != nil {
log.G(ctx).WithFields(fields).WithError(err).Errorf("heartbeat to manager %v failed", s.conn.Peer()) log.G(ctx).WithFields(fields).WithError(err).Errorf("heartbeat to manager %v failed", s.conn.Peer())
if grpc.Code(err) == codes.NotFound { st, _ := status.FromError(err)
if st.Code() == codes.NotFound {
err = errNodeNotRegistered err = errNodeNotRegistered
} }
@ -252,7 +254,8 @@ func (s *session) logSubscriptions(ctx context.Context) error {
for { for {
resp, err := subscriptions.Recv() resp, err := subscriptions.Recv()
if grpc.Code(err) == codes.Unimplemented { st, _ := status.FromError(err)
if st.Code() == codes.Unimplemented {
log.Warning("manager does not support log subscriptions") log.Warning("manager does not support log subscriptions")
// Don't return, because returning would bounce the session // Don't return, because returning would bounce the session
select { select {
@ -303,7 +306,8 @@ func (s *session) watch(ctx context.Context) error {
// If we get a code = 12 desc = unknown method Assignments, try to use tasks // If we get a code = 12 desc = unknown method Assignments, try to use tasks
resp, err = assignmentWatch.Recv() resp, err = assignmentWatch.Recv()
if err != nil { if err != nil {
if grpc.Code(err) != codes.Unimplemented { st, _ := status.FromError(err)
if st.Code() != codes.Unimplemented {
return err return err
} }
tasksFallback = true tasksFallback = true
@ -362,20 +366,21 @@ func (s *session) watch(ctx context.Context) error {
} }
// sendTaskStatus uses the current session to send the status of a single task. // sendTaskStatus uses the current session to send the status of a single task.
func (s *session) sendTaskStatus(ctx context.Context, taskID string, status *api.TaskStatus) error { func (s *session) sendTaskStatus(ctx context.Context, taskID string, taskStatus *api.TaskStatus) error {
client := api.NewDispatcherClient(s.conn.ClientConn) client := api.NewDispatcherClient(s.conn.ClientConn)
if _, err := client.UpdateTaskStatus(ctx, &api.UpdateTaskStatusRequest{ if _, err := client.UpdateTaskStatus(ctx, &api.UpdateTaskStatusRequest{
SessionID: s.sessionID, SessionID: s.sessionID,
Updates: []*api.UpdateTaskStatusRequest_TaskStatusUpdate{ Updates: []*api.UpdateTaskStatusRequest_TaskStatusUpdate{
{ {
TaskID: taskID, TaskID: taskID,
Status: status, Status: taskStatus,
}, },
}, },
}); err != nil { }); err != nil {
// TODO(stevvooe): Dispatcher should not return this error. Status // TODO(stevvooe): Dispatcher should not return this error. Status
// reports for unknown tasks should be ignored. // reports for unknown tasks should be ignored.
if grpc.Code(err) == codes.NotFound { st, _ := status.FromError(err)
if st.Code() == codes.NotFound {
return errTaskUnknown return errTaskUnknown
} }

View file

@ -35,6 +35,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"
) )
const ( const (
@ -352,7 +353,8 @@ func (rca *RootCA) getKEKUpdate(ctx context.Context, leafCert *x509.Certificate,
defer cancel() defer cancel()
response, err := client.GetUnlockKey(ctx, &api.GetUnlockKeyRequest{}) response, err := client.GetUnlockKey(ctx, &api.GetUnlockKeyRequest{})
if err != nil { if err != nil {
if grpc.Code(err) == codes.Unimplemented { // if the server does not support keks, return as if no encryption key was specified s, _ := status.FromError(err)
if s.Code() == codes.Unimplemented { // if the server does not support keks, return as if no encryption key was specified
conn.Close(true) conn.Close(true)
return &KEKData{}, nil return &KEKData{}, nil
} }
@ -838,8 +840,9 @@ func GetRemoteSignedCertificate(ctx context.Context, csr []byte, rootCAPool *x50
stateCtx, cancel := context.WithTimeout(ctx, timeout) stateCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel() defer cancel()
statusResponse, err := caClient.NodeCertificateStatus(stateCtx, statusRequest) statusResponse, err := caClient.NodeCertificateStatus(stateCtx, statusRequest)
s, _ := status.FromError(err)
switch { switch {
case err != nil && grpc.Code(err) != codes.DeadlineExceeded: case err != nil && s.Code() != codes.DeadlineExceeded:
conn.Close(false) conn.Close(false)
// Because IssueNodeCertificate succeeded, if this call failed likely it is due to an issue with this // Because IssueNodeCertificate succeeded, if this call failed likely it is due to an issue with this
// particular connection, so we need to get another. We should try a remote connection - the local node // particular connection, so we need to get another. We should try a remote connection - the local node

View file

@ -962,7 +962,7 @@ func (m *Manager) becomeLeader(ctx context.Context) {
// in order to allow running services on the predefined docker // in order to allow running services on the predefined docker
// networks like `bridge` and `host`. // networks like `bridge` and `host`.
for _, p := range allocator.PredefinedNetworks() { for _, p := range allocator.PredefinedNetworks() {
if err := store.CreateNetwork(tx, newPredefinedNetwork(p.Name, p.Driver)); err != store.ErrNameConflict { if err := store.CreateNetwork(tx, newPredefinedNetwork(p.Name, p.Driver)); err != nil && err != store.ErrNameConflict {
log.G(ctx).WithError(err).Error("failed to create predefined network " + p.Name) log.G(ctx).WithError(err).Error("failed to create predefined network " + p.Name)
} }
} }

View file

@ -9,6 +9,7 @@ import (
"github.com/docker/swarmkit/identity" "github.com/docker/swarmkit/identity"
"github.com/docker/swarmkit/manager/constraint" "github.com/docker/swarmkit/manager/constraint"
"github.com/docker/swarmkit/protobuf/ptypes" "github.com/docker/swarmkit/protobuf/ptypes"
google_protobuf "github.com/gogo/protobuf/types"
) )
// NewTask creates a new task. // NewTask creates a new task.
@ -143,6 +144,14 @@ func InvalidNode(n *api.Node) bool {
n.Spec.Availability == api.NodeAvailabilityDrain n.Spec.Availability == api.NodeAvailabilityDrain
} }
func taskTimestamp(t *api.Task) *google_protobuf.Timestamp {
if t.Status.AppliedAt != nil {
return t.Status.AppliedAt
}
return t.Status.Timestamp
}
// TasksByTimestamp sorts tasks by applied timestamp if available, otherwise // TasksByTimestamp sorts tasks by applied timestamp if available, otherwise
// status timestamp. // status timestamp.
type TasksByTimestamp []*api.Task type TasksByTimestamp []*api.Task
@ -159,15 +168,8 @@ func (t TasksByTimestamp) Swap(i, j int) {
// Less implements the Less method for sorting. // Less implements the Less method for sorting.
func (t TasksByTimestamp) Less(i, j int) bool { func (t TasksByTimestamp) Less(i, j int) bool {
iTimestamp := t[i].Status.Timestamp iTimestamp := taskTimestamp(t[i])
if t[i].Status.AppliedAt != nil { jTimestamp := taskTimestamp(t[j])
iTimestamp = t[i].Status.AppliedAt
}
jTimestamp := t[j].Status.Timestamp
if t[j].Status.AppliedAt != nil {
iTimestamp = t[j].Status.AppliedAt
}
if iTimestamp == nil { if iTimestamp == nil {
return true return true

View file

@ -220,6 +220,16 @@ func (tr *TaskReaper) Run(ctx context.Context) {
} }
} }
// taskInTerminalState returns true if task is in a terminal state.
func taskInTerminalState(task *api.Task) bool {
return task.Status.State > api.TaskStateRunning
}
// taskWillNeverRun returns true if task will never reach running state.
func taskWillNeverRun(task *api.Task) bool {
return task.Status.State < api.TaskStateAssigned && task.DesiredState > api.TaskStateRunning
}
// tick performs task history cleanup. // tick performs task history cleanup.
func (tr *TaskReaper) tick() { func (tr *TaskReaper) tick() {
// this signals that a tick has occurred. it exists solely for testing. // this signals that a tick has occurred. it exists solely for testing.
@ -329,23 +339,21 @@ func (tr *TaskReaper) tick() {
runningTasks := 0 runningTasks := 0
for _, t := range historicTasks { for _, t := range historicTasks {
// Skip tasks which are desired to be running but the current state // Historical tasks can be considered for cleanup if:
// is less than or equal to running. // 1. The task has reached a terminal state i.e. actual state beyond TaskStateRunning.
// This check is important to ignore tasks which are running or need to be running, // 2. The task has not yet become running and desired state is a terminal state i.e.
// but to delete tasks which are either past running, // actual state not yet TaskStateAssigned and desired state beyond TaskStateRunning.
// or have not reached running but need to be shutdown (because of a service update, for example). if taskInTerminalState(t) || taskWillNeverRun(t) {
if t.DesiredState == api.TaskStateRunning && t.Status.State <= api.TaskStateRunning {
// Don't delete running tasks
runningTasks++
continue
}
deleteTasks[t.ID] = struct{}{} deleteTasks[t.ID] = struct{}{}
taskHistory++ taskHistory++
if int64(len(historicTasks)) <= taskHistory { if int64(len(historicTasks)) <= taskHistory {
break break
} }
} else {
// all other tasks are counted as running.
runningTasks++
}
} }
// The only case when we keep the slot dirty at the end of tick() // The only case when we keep the slot dirty at the end of tick()

View file

@ -16,6 +16,7 @@ import (
"github.com/docker/swarmkit/log" "github.com/docker/swarmkit/log"
"github.com/docker/swarmkit/manager/state/raft/membership" "github.com/docker/swarmkit/manager/state/raft/membership"
"github.com/pkg/errors" "github.com/pkg/errors"
"google.golang.org/grpc/status"
) )
const ( const (
@ -238,13 +239,15 @@ func (p *peer) sendProcessMessage(ctx context.Context, m raftpb.Message) error {
} }
// Try doing a regular rpc if the receiver doesn't support streaming. // Try doing a regular rpc if the receiver doesn't support streaming.
if grpc.Code(err) == codes.Unimplemented { s, _ := status.FromError(err)
if s.Code() == codes.Unimplemented {
log.G(ctx).Info("sending message to raft peer using ProcessRaftMessage()") log.G(ctx).Info("sending message to raft peer using ProcessRaftMessage()")
_, err = api.NewRaftClient(p.conn()).ProcessRaftMessage(ctx, &api.ProcessRaftMessageRequest{Message: &m}) _, err = api.NewRaftClient(p.conn()).ProcessRaftMessage(ctx, &api.ProcessRaftMessageRequest{Message: &m})
} }
// Handle errors. // Handle errors.
if grpc.Code(err) == codes.NotFound && grpc.ErrorDesc(err) == membership.ErrMemberRemoved.Error() { s, _ = status.FromError(err)
if s.Code() == codes.NotFound && s.Message() == membership.ErrMemberRemoved.Error() {
p.tr.config.NodeRemoved() p.tr.config.NodeRemoved()
} }
if m.Type == raftpb.MsgSnap { if m.Type == raftpb.MsgSnap {

View file

@ -12,7 +12,7 @@ google.golang.org/grpc v1.12.0
github.com/gogo/protobuf v1.0.0 github.com/gogo/protobuf v1.0.0
github.com/golang/protobuf v1.1.0 github.com/golang/protobuf v1.1.0
github.com/matttproud/golang_protobuf_extensions v1.0.0 github.com/matttproud/golang_protobuf_extensions v1.0.0
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 google.golang.org/genproto 694d95ba50e67b2e363f3483057db5d4910c18f9
# metrics # metrics
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
@ -20,35 +20,35 @@ github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18
# etcd/raft # etcd/raft
github.com/coreos/etcd v3.2.1 github.com/coreos/etcd v3.2.1
github.com/coreos/go-systemd v15 github.com/coreos/go-systemd v17
github.com/coreos/pkg v3 github.com/coreos/pkg v3
github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e
github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6 github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8 github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8
github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5 github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5
github.com/docker/distribution edc3ab29cdff8694dd6feb85cfeb4b5f1b38ed9c github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5
github.com/docker/docker 3d14173a2900b60200d9b1475abd5138f4315981 github.com/docker/docker b9bb3bae5161f931c1dede43c67948c599197f50
github.com/docker/go-connections 7beb39f0b969b075d1325fecb092faf27fd357b6 github.com/docker/go-connections 7beb39f0b969b075d1325fecb092faf27fd357b6
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1 github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef
github.com/docker/libnetwork 1b91bc94094ecfdae41daa465cc0c8df37dfb3dd github.com/docker/libnetwork d00ceed44cc447c77f25cdf5d59e83163bdcb4c9
github.com/opencontainers/runc 4fc53a81fb7c994640722ac585fa9ca548971871 github.com/opencontainers/runc ad0f5255060d36872be04de22f8731f38ef2d7b1
github.com/opencontainers/go-digest 21dfd564fd89c944783d00d069f33e3e7123c448 github.com/opencontainers/go-digest v1.0.0-rc1
github.com/opencontainers/image-spec v1.0.1 github.com/opencontainers/image-spec v1.0.1
github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb
github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0 github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0
github.com/Microsoft/go-winio v0.4.6 github.com/Microsoft/go-winio v0.4.8
github.com/sirupsen/logrus v1.0.3 github.com/sirupsen/logrus v1.0.3
github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904 github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904
github.com/cloudflare/cfssl 1.3.2 github.com/cloudflare/cfssl 1.3.2
github.com/dustin/go-humanize 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0 github.com/dustin/go-humanize 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
github.com/fernet/fernet-go 1b2437bc582b3cfbb341ee5a29f8ef5b42912ff2 github.com/fernet/fernet-go 1b2437bc582b3cfbb341ee5a29f8ef5b42912ff2
github.com/google/certificate-transparency-go 5ab67e519c93568ac3ee50fd6772a5bcf8aa460d github.com/google/certificate-transparency-go v1.0.20
github.com/hashicorp/go-immutable-radix 8e8ed81f8f0bf1bdd829593fdd5c29922c1ea990 github.com/hashicorp/go-immutable-radix 826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git
github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad
github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4 github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
@ -60,8 +60,8 @@ github.com/rcrowley/go-metrics 51425a2415d21afadfd55cd93432c0bc69e9598d
github.com/spf13/cobra 8e91712f174ced10270cf66615e0a9127e7c4de5 github.com/spf13/cobra 8e91712f174ced10270cf66615e0a9127e7c4de5
github.com/spf13/pflag 7f60f83a2c81bc3c3c0d5297f61ddfa68da9d3b7 github.com/spf13/pflag 7f60f83a2c81bc3c3c0d5297f61ddfa68da9d3b7
github.com/stretchr/testify v1.1.4 github.com/stretchr/testify v1.1.4
golang.org/x/crypto 650f4a345ab4e5b245a3034b110ebc7299e68186 golang.org/x/crypto 1a580b3eff7814fc9b40602fd35256c63b50f491
golang.org/x/net 7dcfb8076726a3fdd9353b6b8a1f1b6be6811bd6 golang.org/x/net 0ed95abb35c445290478a5348a7b38bb154135fd
golang.org/x/sys 37707fdb30a5b38865cfb95e5aab41707daec7fd golang.org/x/sys 37707fdb30a5b38865cfb95e5aab41707daec7fd
golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756 golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756
golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb