agent/engine/docker_task_engine.go
func (engine *DockerTaskEngine) sweepTask(task *apitask.Task) {
	for _, cont := range task.Containers {
		err := engine.removeContainer(task, cont)
		if err != nil {
			seelog.Debugf("Task engine [%s]: unable to remove old container [%s]: %v",
				task.Arn, cont.Name, err)
		}
		// Internal container(created by ecs-agent) state isn't recorded
		if cont.IsInternal() {
			continue
		}
		err = engine.imageManager.RemoveContainerReferenceFromImageState(cont)
		if err != nil {
			seelog.Errorf("Task engine [%s]: Unable to remove container [%s] reference from image state: %v",
				task.Arn, cont.Name, err)
		}
	}

	// Clean metadata directory for task
	if engine.cfg.ContainerMetadataEnabled {
		err := engine.metadataManager.Clean(task.Arn)
		if err != nil {
			seelog.Warnf("Task engine [%s]: clean task metadata failed: %v", task.Arn, err)
		}
	}
	engine.saver.Save()
}
func (engine *DockerTaskEngine) sweepTask(task *apitask.Task) {
	for _, cont := range task.Containers {
		err := engine.removeContainer(task, cont)
		if err != nil {
			seelog.Debugf("Task engine [%s]: unable to remove old container [%s]: %v",
				task.Arn, cont.Name, err)
		}
		// Internal container(created by ecs-agent) state isn't recorded
		if cont.IsInternal() {
			continue
		}
		err = engine.imageManager.RemoveContainerReferenceFromImageState(cont)
		if err != nil {
			seelog.Errorf("Task engine [%s]: Unable to remove container [%s] reference from image state: %v",
				task.Arn, cont.Name, err)
		}
	}

	// Clean metadata directory for task
	if engine.cfg.ContainerMetadataEnabled {
		err := engine.metadataManager.Clean(task.Arn)
		if err != nil {
			seelog.Warnf("Task engine [%s]: clean task metadata failed: %v", task.Arn, err)
		}
	}
	engine.saver.Save()
}
func ( engine * DockerTaskEngine ) sweepTask ( task * apitask . Task ) { for _ , cont := range task . Containers { err := engine . removeContainer ( task , cont ) if err != nil { seelog . Debugf ( " " , task . Arn , cont . Name , err ) } // Internal container(created by ecs-agent) state isn't recorded if cont . IsInternal ( ) { continue } err = engine . imageManager . RemoveContainerReferenceFromImageState ( cont ) if err != nil { seelog . Errorf ( " " , task . Arn , cont . Name , err ) } } // Clean metadata directory for task if engine . cfg . ContainerMetadataEnabled { err := engine . metadataManager . Clean ( task . Arn ) if err != nil { seelog . Warnf ( " " , task . Arn , err ) } } engine . saver . Save ( ) }
// sweepTask deletes all the containers associated with a task
sweepTask deletes all the containers associated with a task