code: func (nodeInfo *NodeInfo) removeTask(t *api.Task) bool {
  	oldTask, ok := nodeInfo.Tasks[t.ID]
  	if !ok {
  		return false
  	}
  
  	delete(nodeInfo.Tasks, t.ID)
  	if oldTask.DesiredState <= api.TaskStateRunning {
  		nodeInfo.ActiveTasksCount--
  		nodeInfo.ActiveTasksCountByService[t.ServiceID]--
  	}
  
  	if t.Endpoint != nil {
  		for _, port := range t.Endpoint.Ports {
  			if port.PublishMode == api.PublishModeHost && port.PublishedPort != 0 {
  				portSpec := hostPortSpec{protocol: port.Protocol, publishedPort: port.PublishedPort}
  				delete(nodeInfo.usedHostPorts, portSpec)
  			}
  		}
  	}
  
  	reservations := taskReservations(t.Spec)
  	resources := nodeInfo.AvailableResources
  
  	resources.MemoryBytes += reservations.MemoryBytes
  	resources.NanoCPUs += reservations.NanoCPUs
  
  	if nodeInfo.Description == nil || nodeInfo.Description.Resources == nil ||
  		nodeInfo.Description.Resources.Generic == nil {
  		return true
  	}
  
  	taskAssigned := t.AssignedGenericResources
  	nodeAvailableResources := &resources.Generic
  	nodeRes := nodeInfo.Description.Resources.Generic
  	genericresource.Reclaim(nodeAvailableResources, taskAssigned, nodeRes)
  
  	return true
  }
docs: // removeTask removes a task from nodeInfo if it's tracked there, and returns true
  // if nodeInfo was modified.