Skip to content

Commit

Permalink
Add task stop verification ack to ecs-agent module
Browse files Browse the repository at this point in the history
  • Loading branch information
ohsoo committed Jul 21, 2023
1 parent 0be8253 commit b230732
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,20 @@ func (r *taskStopVerificationACKResponder) handleTaskStopVerificationACK(message
return errors.New("Invalid messageID received: " + ackMessageID + " Manifest Message ID: " + manifestMessageID)
}

// Reset the message id so that the message with same message id is not processed twice.
r.messageIDAccessor.SetMessageID("")

// Loop through all tasks in the verified stop list and set the desired status of each one to STOPPED.
tasksToStop := message.StopTasks
for _, task := range tasksToStop {
taskARN := aws.StringValue(task.TaskArn)
metricFields := map[string]interface{}{
"MessageID": aws.StringValue(message.MessageId),
"TaskARN": taskARN,
metricFields := logger.Fields{
field.MessageID: aws.StringValue(message.MessageId),
field.TaskARN: taskARN,
}
r.metricsFactory.New(metrics.TaskStoppedMetricName).WithFields(metricFields).Done(nil)

// Send request to the task stopper to stop the task this will be executed asynchronously
// in the context of the task stopper's message channel.
// Send request to the task stopper to stop the task.
logger.Info("Sending message to task stopper to stop task", logger.Fields{
field.TaskARN: taskARN,
})
Expand Down
8 changes: 8 additions & 0 deletions ecs-agent/metrics/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ const (
// AttachResourceResponder
attachResourceResponderNamespace = "ResourceAttachment"
ResourceValidationMetricName = attachResourceResponderNamespace + ".Validation"

// TaskManifestResponder
taskManifestResponderNamespace = "TaskManifestResponder"
TaskManifestHandlingDuration = taskManifestResponderNamespace + ".Duration"

// TaskStopVerificationACKResponder
taskStopVerificationACKResponderNamespace = "TaskStopVeificationACKResponder"
TaskStoppedMetricName = taskStopVerificationACKResponderNamespace + ".TaskStopped"
)

0 comments on commit b230732

Please sign in to comment.