// tasksEqual returns true if the tasks are functionaly equal, ignoring status, // version and other superfluous fields. // // This used to decide whether or not to propagate a task update to a controller. func tasksEqual(a, b *api.Task) bool { a, b = a.Copy(), b.Copy() a.Status, b.Status = api.TaskStatus{}, api.TaskStatus{} a.Meta, b.Meta = api.Meta{}, api.Meta{} return reflect.DeepEqual(a, b) }
func (w *worker) startTask(ctx context.Context, tx *bolt.Tx, task *api.Task) error { w.taskevents.Publish(task.Copy()) _, err := w.taskManager(ctx, tx, task) // side-effect taskManager creation. if err != nil { log.G(ctx).WithError(err).Error("failed to start taskManager") } // TODO(stevvooe): Add start method for taskmanager return nil }
func newTaskManager(ctx context.Context, task *api.Task, ctlr exec.Controller, reporter StatusReporter) *taskManager { t := &taskManager{ task: task.Copy(), ctlr: ctlr, reporter: reporter, updateq: make(chan *api.Task), shutdown: make(chan struct{}), closed: make(chan struct{}), } go t.run(ctx) return t }
// PutTask places the task into the database. func PutTask(tx *bolt.Tx, task *api.Task) error { return withCreateTaskBucketIfNotExists(tx, task.ID, func(bkt *bolt.Bucket) error { task = task.Copy() task.Status = api.TaskStatus{} // blank out the status. p, err := proto.Marshal(task) if err != nil { return err } return bkt.Put(bucketKeyData, p) }) }