Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default wait timeout for attachments from ACS #3914

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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

17 changes: 14 additions & 3 deletions ecs-agent/acs/session/attach_resource_responder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (

const (
AttachResourceMessageName = "ConfirmAttachmentMessage"
// DefaultAttachmentWaitTimeoutInMs is the default timeout, 5 minutes, for handling the attachments from ACS.
DefaultAttachmentWaitTimeoutInMs = 300000
)

type ResourceHandler interface {
Expand Down Expand Up @@ -78,8 +80,17 @@ func (r *attachResourceResponder) handleAttachMessage(message *ecsacs.ConfirmAtt
}

messageID := aws.StringValue(message.MessageId)
expiresAt := receivedAt.Add(
time.Duration(aws.Int64Value(message.WaitTimeoutMs)) * time.Millisecond)
// Set a default wait timeout (5m) for the attachment message from ACS if not provided.
// For example, the attachment payload for the EBS attach might not have the property.
waitTimeoutMs := aws.Int64Value(message.WaitTimeoutMs)
if waitTimeoutMs == 0 {
waitTimeoutMs = DefaultAttachmentWaitTimeoutInMs
}
logger.Debug("Waiting for the resource attachment to be ready",
logger.Fields{
"WaitTimeoutMs": waitTimeoutMs,
})
expiresAt := receivedAt.Add(time.Duration(waitTimeoutMs) * time.Millisecond)
go r.resourceHandler.HandleResourceAttachment(&resource.ResourceAttachment{
AttachmentInfo: attachmentinfo.AttachmentInfo{
TaskARN: aws.StringValue(message.TaskArn),
Expand Down Expand Up @@ -194,7 +205,7 @@ func validateAttachmentAndReturnProperties(message *ecsacs.ConfirmAttachmentMess
return attachmentProperties, nil
}

// For "EphemeralStorage" and "ElasticBlockStorage", ACS is using resourceType to indicate its attachment type.
// For legacy EBS volumes("EphemeralStorage" and "ElasticBlockStorage"), ACS is using resourceType to indicate its attachment type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: For my understanding, is it appropriate referring to these storage means as legacy? Are we planning to deprecate them at any point already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to deprecate them at any point already?

I don't think so. I think we will continue to support both but won't change them much.

I will confirm with @fierlion since this comment is from this PR https://github.com/aws/amazon-ecs-agent/pull/3911/files/9597f968e447852d88a3fb7d75a7a550fba24ffb#r1327869451

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: My comment's intent was to remove the words EphemeralStorage altogether. This is a nit but we should follow up and fix this comment.

err = resource.ValidateResourceByResourceType(attachmentProperties)
if err != nil {
return nil, errors.Wrap(err, "resource attachment validation by resource type failed ")
Expand Down