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

Adding support for ebs volumes within task handler #3917

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

mye956
Copy link
Contributor

@mye956 mye956 commented Sep 20, 2023

Summary

The goal of this PR is to add functionality to handle and process task payload with EBS volume attachments. Once the payload has been processed, agent will spin up the task docker container and mount the EBS volume within the host instance.

Implementation details

  • Minor changes to task.go
    • Added a new attachment type for EBS Volumes
  • Modified task_attachment_handler.go
    • Modified handleTaskAttachments: The functionality will now be parsing the list of attachment that's within the task payload (in the form of the shared Task struct). If there are any attachments of type AmazonElasticBlockStorage then we'll parse + validate it into an object of type EBSTaskVolumeConfig via the ParseEBSTaskVolumeAttachment function. At the end, we'll append each new EBSTaskVolumeConfig object to the list of volumes for the managed task.
  • Modified taskvolume.go
    • Added new functionality to unmarshalEBSVolume: This function will unmarshal raw data (in JSON form) and convert into an object of type EBSTaskVolumeConfig. This is used for saving to state.
  • Minor changes to dockervolume.go:
    • Added new functionality to Source: Returns the complete source host path that's used to bind mount with the task docker container
  • Added dockervolume_ebs.go to taskresource/volume
    • Added new functionality to ParseEBSTaskVolumeAttachment: Parses and validates an EBS volume attachment from the task payload sent from ACS. Returns a new object of typed EBSTaskVolumeConfig
    • Added new functionality validateEBSTaskVolumeAttachment: Validates that the parsed EBSTaskVolumeConfig has VolumeId, VolumeName, and SourceVolumeHostPath set and non-empty which is required for task start and stop.
    • New struct EBSTaskVolumeConfigwhich is used to store all of the attachment information of the EBS volume for a managed task

Testing

Unit tests

New tests cover the changes: Yes

Description for the changelog

Add support to handle task payload with EBS volume attachments.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mye956 mye956 force-pushed the ebstaskhandler branch 2 times, most recently from 5e3f264 to 2cda585 Compare September 20, 2023 23:48
@mye956 mye956 changed the title WIP Adding support for ebs volumes within task handler Adding support for ebs volumes within task handler Sep 21, 2023
@mye956 mye956 marked this pull request as ready for review September 21, 2023 00:35
@mye956 mye956 requested a review from a team as a code owner September 21, 2023 00:35
Copy link
Contributor

@xxx0624 xxx0624 left a comment

Choose a reason for hiding this comment

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

agent/taskresource/volume/dockervolume_ebs.go Outdated Show resolved Hide resolved
agent/api/task/task.go Outdated Show resolved Hide resolved
@mye956 mye956 force-pushed the ebstaskhandler branch 4 times, most recently from b285695 to 8481805 Compare September 21, 2023 22:44
@mye956 mye956 force-pushed the ebstaskhandler branch 2 times, most recently from bd970b3 to 5d94a03 Compare September 21, 2023 23:08
xxx0624
xxx0624 previously approved these changes Sep 21, 2023
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs"
acssession "github.com/aws/amazon-ecs-agent/ecs-agent/acs/session"
"github.com/aws/amazon-ecs-agent/ecs-agent/acs/session/testconst"
"github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
apira "github.com/aws/amazon-ecs-agent/ecs-agent/api/resource"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we name it apiresource instead of apira ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call out, that makes it more clearer. thanks Utsa!

if property == nil {
return nil, fmt.Errorf("failed to parse task ebs attachment, encountered nil property")
}
if aws.StringValue(property.Value) == "" {
Copy link
Contributor

@chienhanlin chienhanlin Sep 22, 2023

Choose a reason for hiding this comment

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

Discussed offline. By design, an initial validation for non-empty property value is done here. The required properties will be validate again in func validateEBSTaskVolumeAttachment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

@mye956 mye956 merged commit 6ba1af7 into aws:dev Sep 22, 2023
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants