agent/engine/dockerstate/docker_task_engine_state.go
func (state *DockerTaskEngineState) RemoveTask(task *apitask.Task) {
	state.lock.Lock()
	defer state.lock.Unlock()

	task, ok := state.tasks[task.Arn]
	if !ok {
		seelog.Warnf("Failed to locate task %s for removal from state", task.Arn)
		return
	}
	delete(state.tasks, task.Arn)
	if ip, ok := state.taskToIPUnsafe(task.Arn); ok {
		delete(state.ipToTask, ip)
	}

	containerMap, ok := state.taskToID[task.Arn]
	if !ok {
		seelog.Warnf("Failed to locate containerMap for task %s for removal from state", task.Arn)
		return
	}
	delete(state.taskToID, task.Arn)

	for _, dockerContainer := range containerMap {
		state.removeIDToContainerTaskUnsafe(dockerContainer)
		// remove v3 endpoint mappings
		state.removeV3EndpointIDToTaskContainerUnsafe(dockerContainer.Container.V3EndpointID)
	}
}
func (state *DockerTaskEngineState) RemoveTask(task *apitask.Task) {
	state.lock.Lock()
	defer state.lock.Unlock()

	task, ok := state.tasks[task.Arn]
	if !ok {
		seelog.Warnf("Failed to locate task %s for removal from state", task.Arn)
		return
	}
	delete(state.tasks, task.Arn)
	if ip, ok := state.taskToIPUnsafe(task.Arn); ok {
		delete(state.ipToTask, ip)
	}

	containerMap, ok := state.taskToID[task.Arn]
	if !ok {
		seelog.Warnf("Failed to locate containerMap for task %s for removal from state", task.Arn)
		return
	}
	delete(state.taskToID, task.Arn)

	for _, dockerContainer := range containerMap {
		state.removeIDToContainerTaskUnsafe(dockerContainer)
		// remove v3 endpoint mappings
		state.removeV3EndpointIDToTaskContainerUnsafe(dockerContainer.Container.V3EndpointID)
	}
}
func ( state * DockerTaskEngineState ) RemoveTask ( task * apitask . Task ) { state . lock . Lock ( ) defer state . lock . Unlock ( ) task , ok := state . tasks [ task . Arn ] if ! ok { seelog . Warnf ( " " , task . Arn ) return } delete ( state . tasks , task . Arn ) if ip , ok := state . taskToIPUnsafe ( task . Arn ) ; ok { delete ( state . ipToTask , ip ) } containerMap , ok := state . taskToID [ task . Arn ] if ! ok { seelog . Warnf ( " " , task . Arn ) return } delete ( state . taskToID , task . Arn ) for _ , dockerContainer := range containerMap { state . removeIDToContainerTaskUnsafe ( dockerContainer ) // remove v3 endpoint mappings state . removeV3EndpointIDToTaskContainerUnsafe ( dockerContainer . Container . V3EndpointID ) } }
// RemoveTask removes a task from this state. It removes all containers and
// other associated metadata. It does acquire the write lock.
RemoveTask removes a task from this state . It removes all containers and other associated metadata . It does acquire the write lock .