code: func (na *cnmNetworkAllocator) AllocateTask(t *api.Task) error {
  	for i, nAttach := range t.Networks {
  		if localNet := na.getNetwork(nAttach.Network.ID); localNet != nil && localNet.isNodeLocal {
  			continue
  		}
  		if err := na.allocateNetworkIPs(nAttach); err != nil {
  			if err := na.releaseEndpoints(t.Networks[:i]); err != nil {
  				log.G(context.TODO()).WithError(err).Errorf("failed to release IP addresses while rolling back allocation for task %s network %s", t.ID, nAttach.Network.ID)
  			}
  			return errors.Wrapf(err, "failed to allocate network IP for task %s network %s", t.ID, nAttach.Network.ID)
  		}
  	}
  
  	na.tasks[t.ID] = struct{}{}
  
  	return nil
  }
docs: // AllocateTask allocates all the endpoint resources for all the
  // networks that a task is attached to.