Skip to content
Merged
Show file tree
Hide file tree
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ checkprotos: generate ## check if protobufs needs to be generated again
# imports
vet: binaries ## run go vet
@echo "🐳 $@"
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | grep -v 'timestamp_test.go' | grep -v 'exit status 1' | tee /dev/stderr)"
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"

fmt: ## run go fmt
@echo "🐳 $@"
@test -z "$$(gofmt -s -l . | grep -v vendor/ | grep -v ".pb.go$$" | tee /dev/stderr)" || \
(echo "👹 please format Go code with 'gofmt -s'" && false)
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
(echo "👹 please indent proto files with tabs only" && false)
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "id = " {} \; | grep -v gogoproto.customname | tee /dev/stderr)" || \
(echo "👹 id fields in proto files must have a gogoproto.customname set" && false)
Expand Down
2 changes: 1 addition & 1 deletion agent/exec/container/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (c *containerAdapter) events(ctx context.Context) (<-chan events.Message, <
}

func (c *containerAdapter) shutdown(ctx context.Context) error {
return c.client.ContainerStop(ctx, c.container.name(), int(c.container.spec().StopGracePeriod.Seconds()))
return c.client.ContainerStop(ctx, c.container.name(), int(c.container.spec().StopGracePeriod.Seconds))
}

func (c *containerAdapter) terminate(ctx context.Context) error {
Expand Down
6 changes: 3 additions & 3 deletions agent/exec/container/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/docker/swarm-v2/api"
"github.com/docker/swarm-v2/identity"
"github.com/docker/swarm-v2/log"
"github.com/docker/swarm-v2/protobuf/ptypes"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
Expand Down Expand Up @@ -304,9 +305,8 @@ func genTask(t *testing.T) *api.Task {
Runtime: &api.Task_Container{
Container: &api.Container{
Spec: api.ContainerSpec{
Image: reference,

StopGracePeriod: 10 * time.Second,
Image: reference,
StopGracePeriod: *ptypes.DurationProto(10 * time.Second),
},
},
},
Expand Down
10 changes: 8 additions & 2 deletions agent/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/swarm-v2/api"
"github.com/docker/swarm-v2/log"
"github.com/docker/swarm-v2/protobuf/ptypes"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -173,10 +174,15 @@ func (s *session) heartbeat(ctx context.Context) error {
return err
}

heartbeat.Reset(resp.Period)
period, err := ptypes.Duration(&resp.Period)
if err != nil {
return err
}

heartbeat.Reset(period)
log.G(ctx).WithFields(
logrus.Fields{
"period": resp.Period,
"period": period,
"grpc.duration": time.Since(start),
}).Debugf("heartbeat")
case <-s.closed:
Expand Down
131 changes: 72 additions & 59 deletions api/dispatcher.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/dispatcher.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "types.proto";
import "objects.proto";
import "gogoproto/gogo.proto";
import "plugin/plugin.proto";
import "duration/duration.proto"; // TODO(stevvooe): use our own until we fix gogoproto/deepcopy

// Dispatcher is the API provided by a manager group for agents to connect to. Agents
// connect to this service to receive task assignments and report status.
Expand Down Expand Up @@ -125,7 +126,7 @@ message HeartbeatRequest {
message HeartbeatResponse {
// Period is the duration to wait before sending the next heartbeat.
// Well-behaved agents should update this on every heartbeat round trip.
uint64 Period = 1 [(gogoproto.customtype) = "time.Duration", (gogoproto.nullable) = false];
Duration period = 1 [(gogoproto.nullable) = false];
}

message UpdateTaskStatusRequest {
Expand Down
Loading