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 @@ -52,13 +52,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 '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' | grep -v 'timestamp_test.go' | grep -v '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 '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.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
27 changes: 19 additions & 8 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/docker/swarm-v2/agent/exec"
"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"
)
Expand Down Expand Up @@ -404,6 +405,13 @@ func (a *Agent) updateStatus(ctx context.Context, report taskStatusReport) error
status.State = report.state
}

tsp, err := ptypes.TimestampProto(report.timestamp)
if err != nil {
return err
}

status.Timestamp = tsp

if reflect.DeepEqual(status, original) {
return errTaskStatusUpdateNoChange
}
Expand Down Expand Up @@ -522,10 +530,11 @@ func (a *Agent) removeTask(ctx context.Context, t *api.Task) error {
}

type taskStatusReport struct {
taskID string
state api.TaskState
err error
response chan error
timestamp time.Time
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where does this get set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

status has the type *api.TaskStatus, not taskStatusReport.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

taskID string
state api.TaskState
err error
response chan error
}

func (a *Agent) report(ctx context.Context, taskID string, state api.TaskState, errs ...error) error {
Expand All @@ -543,10 +552,12 @@ func (a *Agent) report(ctx context.Context, taskID string, state api.TaskState,

select {
case a.statusq <- taskStatusReport{
taskID: taskID,
state: state,
err: err,
response: response}:
timestamp: time.Now(),
taskID: taskID,
state: state,
err: err,
response: response,
}:
select {
case err := <-response:
return err
Expand Down
2 changes: 1 addition & 1 deletion api/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:generate protoc -I.:../vendor:../vendor/github.com/gogo/protobuf --gogoswarm_out=plugins=grpc+deepcopy+raftproxy,import_path=github.com/docker/swarm-v2/api,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto:. types.proto specs.proto objects.proto cluster.proto dispatcher.proto raft.proto
//go:generate protoc -I.:../vendor:../vendor/github.com/gogo/protobuf --gogoswarm_out=plugins=grpc+deepcopy+raftproxy,import_path=github.com/docker/swarm-v2/api,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto,Mtimestamp/timestamp.proto=github.com/docker/swarm-v2/api/timestamp:. types.proto specs.proto objects.proto cluster.proto dispatcher.proto raft.proto

// BUG(stevvooe): The generation line below is nearly identical to the line
// above, except that deepcopy is disabled. There is a bug in deepcopy that
Expand Down
3 changes: 3 additions & 0 deletions api/timestamp/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//go:generate protoc -I.:../../vendor:../../vendor/github.com/gogo/protobuf --gogoswarm_out=plugins=grpc+deepcopy+raftproxy,import_path=github.com/docker/swarm-v2/api/timestamp,Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto:. timestamp.proto

package timestamp
Loading