(ctx context.Context, batch *store.Batch, t *api.Task)
| 1372 | } |
| 1373 | |
| 1374 | func (a *Allocator) commitAllocatedTask(ctx context.Context, batch *store.Batch, t *api.Task) error { |
| 1375 | retError := batch.Update(func(tx store.Tx) error { |
| 1376 | err := store.UpdateTask(tx, t) |
| 1377 | |
| 1378 | if err == store.ErrSequenceConflict { |
| 1379 | storeTask := store.GetTask(tx, t.ID) |
| 1380 | taskUpdateNetworks(storeTask, t.Networks) |
| 1381 | taskUpdateEndpoint(storeTask, t.Endpoint) |
| 1382 | if storeTask.Status.State < api.TaskStatePending { |
| 1383 | storeTask.Status = t.Status |
| 1384 | } |
| 1385 | err = store.UpdateTask(tx, storeTask) |
| 1386 | } |
| 1387 | |
| 1388 | return errors.Wrapf(err, "failed updating state in store transaction for task %s", t.ID) |
| 1389 | }) |
| 1390 | |
| 1391 | if retError == nil { |
| 1392 | log.G(ctx).Debugf("committed allocated task %v, state update %v", t.GetID(), t.Status) |
| 1393 | } |
| 1394 | |
| 1395 | return retError |
| 1396 | } |
| 1397 | |
| 1398 | func (a *Allocator) procUnallocatedNetworks(ctx context.Context) { |
| 1399 | nc := a.netCtx |
no test coverage detected