[19.03] vendor: swarmkit 0b8364e7d08aa0e972241eb59ae981a67a587a0e

full diff: 062b694b46...0b8364e7d0

- Fix leaking tasks.db

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-04-16 21:55:43 +02:00
parent 25b82fa9b8
commit e4f239d68e
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 27 additions and 5 deletions

View file

@ -128,7 +128,7 @@ github.com/containerd/ttrpc 92c8520ef9f86600c650dd540266
github.com/gogo/googleapis d31c731455cb061f42baff3bda55bad0118b126b # v1.2.0
# cluster
github.com/docker/swarmkit 062b694b46c0744d601eebef79f3f7433d808a04 # bump_v19.03 branch
github.com/docker/swarmkit 0b8364e7d08aa0e972241eb59ae981a67a587a0e # bump_v19.03 branch
github.com/gogo/protobuf ba06b47c162d49f2af050fb4c75bcbc86a159d5c # v1.2.1
github.com/golang/protobuf aa810b61a9c79d51363740d207bb46cf8e620ed5 # v1.2.0
github.com/cloudflare/cfssl 5d63dbd981b5c408effbb58c442d54761ff94fbd # 1.3.2

View file

@ -131,7 +131,9 @@ func PutTask(tx *bolt.Tx, task *api.Task) error {
// PutTaskStatus updates the status for the task with id.
func PutTaskStatus(tx *bolt.Tx, id string, status *api.TaskStatus) error {
return withCreateTaskBucketIfNotExists(tx, id, func(bkt *bolt.Bucket) error {
// this used to be withCreateTaskBucketIfNotExists, but that could lead
// to weird race conditions, and was not necessary.
return withTaskBucket(tx, id, func(bkt *bolt.Bucket) error {
p, err := proto.Marshal(status)
if err != nil {
return err

View file

@ -278,10 +278,15 @@ func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.Assig
removeTaskAssignment := func(taskID string) error {
ctx := log.WithLogger(ctx, log.G(ctx).WithField("task.id", taskID))
if err := SetTaskAssignment(tx, taskID, false); err != nil {
log.G(ctx).WithError(err).Error("error setting task assignment in database")
// if a task is no longer assigned, then we do not have to keep track
// of it. a task will only be unassigned when it is deleted on the
// manager. instead of SetTaskAssginment to true, we'll just remove the
// task now.
if err := DeleteTask(tx, taskID); err != nil {
log.G(ctx).WithError(err).Error("error removing de-assigned task")
return err
}
return err
return nil
}
// If this was a complete set of assignments, we're going to remove all the remaining
@ -500,6 +505,21 @@ func (w *worker) newTaskManager(ctx context.Context, tx *bolt.Tx, task *api.Task
// updateTaskStatus reports statuses to listeners, read lock must be held.
func (w *worker) updateTaskStatus(ctx context.Context, tx *bolt.Tx, taskID string, status *api.TaskStatus) error {
if err := PutTaskStatus(tx, taskID, status); err != nil {
// we shouldn't fail to put a task status. however, there exists the
// possibility of a race in which we try to put a task status after the
// task has been deleted. because this whole contraption is a careful
// dance of too-tightly-coupled concurrent parts, fixing tht race is
// fraught with hazards. instead, we'll recognize that it can occur,
// log the error, and then ignore it.
if err == errTaskUnknown {
// log at info level. debug logging in docker is already really
// verbose, so many people disable it. the race that causes this
// behavior should be very rare, but if it occurs, we should know
// about it, because if there is some case where it is _not_ rare,
// then knowing about it will go a long way toward debugging.
log.G(ctx).Info("attempted to update status for a task that has been removed")
return nil
}
log.G(ctx).WithError(err).Error("failed writing status to disk")
return err
}