Skip to content

Commit

Permalink
dont consume resources for acs stopped tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekchaudhry committed Jun 15, 2023
1 parent abf9bd1 commit b1c74ce
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions agent/engine/docker_task_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ func (engine *DockerTaskEngine) monitorQueuedTasks(ctx context.Context) {
if err != nil {
break
}
taskDesiredStatus := task.GetDesiredStatus()
if taskDesiredStatus.Terminal() {
logger.Info("Task desired status STOPPED while waiting for host resources, progressing without consuming resources", logger.Fields{field.TaskARN: task.Arn})
engine.returnWaitingTask()
continue
}
taskHostResources := task.ToHostResources()
consumed, err := task.engine.hostResourceManager.consume(task.Arn, taskHostResources)
if err != nil {
Expand All @@ -409,6 +415,12 @@ func (engine *DockerTaskEngine) monitorQueuedTasks(ctx context.Context) {
}
}

// To be called when resources are not to be consumed by host resource manager, just dequeues and returns
func (engine *DockerTaskEngine) returnWaitingTask() {
task, _ := engine.dequeueTask()
task.consumedHostResourceEvent <- struct{}{}
}

func (engine *DockerTaskEngine) failWaitingTask(err error) {
task, _ := engine.dequeueTask()
logger.Error(fmt.Sprintf("Error consuming resources due to invalid task config : %s", err.Error()), logger.Fields{field.TaskARN: task.Arn})
Expand Down

0 comments on commit b1c74ce

Please sign in to comment.