code: func (r *Orchestrator) FixTask(ctx context.Context, batch *store.Batch, t *api.Task) {
  	// If we already set the desired state past TaskStateRunning, there is no
  	// further action necessary.
  	if t.DesiredState > api.TaskStateRunning {
  		return
  	}
  
  	var (
  		n       *api.Node
  		service *api.Service
  	)
  	batch.Update(func(tx store.Tx) error {
  		if t.NodeID != "" {
  			n = store.GetNode(tx, t.NodeID)
  		}
  		if t.ServiceID != "" {
  			service = store.GetService(tx, t.ServiceID)
  		}
  		return nil
  	})
  
  	if !orchestrator.IsReplicatedService(service) {
  		return
  	}
  
  	if t.Status.State > api.TaskStateRunning ||
  		(t.NodeID != "" && orchestrator.InvalidNode(n)) {
  		r.restartTasks[t.ID] = struct{}{}
  		return
  	}
  }
docs: // FixTask validates a task with the current cluster settings, and takes
  // action to make it conformant. it's called at orchestrator initialization.