-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(ecs): add maxSwap
and swappiness
properties to LinuxParameters
#18703
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
feat(ecs): add maxSwap
and swappiness
properties to LinuxParameters
#18703
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this contribution, @flavioleggio!
Some requests:
- Please add validation somewhere for the restrictions of maxSwap and swappiness - e.g. min/max values, if swappiness is supplied but maxSwap is not then swapping won't occur, these values can't be used with Fargate tasks
- Have you deployed an ECS service with these parameters? and does it actually work as expected? I am asking because of these comments: aws-ecs: Support MaxSwap and Swappiness in LinuxParameters #18460 (comment) and aws-ecs: Support MaxSwap and Swappiness in LinuxParameters #18460 (comment). If there is some actions users need to take for this to work after deployment, we need to document it. Or, hopefully do it for them in the cfn template.
- Please include an integration test.
Pull request has been modified.
Thanks for your review @madeline-k
I deployed a test stack and the parameters were correctly defined in the resulting task definition. However, I had no chance to check if swap memory was available inside the container and I did not figure out how, actually. Maybe I should ssh into the cluster instance and exec a
I developed an integration test, but I have no permissions to create the VPC that I need for the ECS cluster in my company account, thus I cannot run the full integ test. What is the policy here? Should I commit the test without the corresponding |
You're correct, you can't commit an integration test without the corresponding .expected.json template. Maybe I can help out here. Can you add the integration test to this PR? then I can run it and generate the expected.json template, and I'll push that to your branch. |
Ok, I’ll try to post it tomorrow |
// packages/@aws-cdk/aws-ecs/test/ec2/integ.swap-parameters.ts
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import * as ecs from '../../lib';
import { LinuxParameters } from '../../lib';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'aws-ecs-integ');
const vpc = new ec2.Vpc(stack, 'Vpc', { maxAzs: 2 });
// ECS cluster to host EC2 task
const cluster = new ecs.Cluster(stack, 'EcsCluster', { vpc });
cluster.addCapacity('DefaultAutoScalingGroup', {
instanceType: new ec2.InstanceType('t2.micro'),
});
// define task to run the container
const taskDefinition = new ecs.Ec2TaskDefinition(stack, 'TaskDefinition', {
networkMode: ecs.NetworkMode.AWS_VPC,
});
// define linux parameters to enable swap
const linuxParameters = new LinuxParameters(stack, 'LinuxParameters', {
maxSwap: 5e3,
swappiness: 90,
});
// define container with linux parameters
new ecs.ContainerDefinition(stack, 'Container', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
linuxParameters,
memoryLimitMiB: 256,
taskDefinition,
});
// define a service to run the task definition
new ecs.Ec2Service(stack, 'Service', {
cluster,
taskDefinition,
});
app.synth(); |
test file provided by @flavioleggio and expected file from test run
@flavioleggio Apologies for the long wait on this. I've run the test that you wrote and pushed the result to an |
@flavioleggio Well, this is my bad. I didn't notice that the integration test was the old style and not the new. We'll need to update to the new style. I'll take care of that and run them for the expected output within the next week. |
@Mergifyio update |
test file provided by @flavioleggio and expected file from test run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheRealAmazonKendra Looks good now, I think we need the Token changes and then the PR is ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have one requested change here for this PR.
Changing types is a breaking change, so we need that added before the PR is merged.
In an ideal world, I think there would be more validation for this - error message when maxSwap
is omitted, but swappiness
is provided, and verify that these params can only be used when EC2 launch type is used. But we can add more validation in future PRs. I wouldn't hold this one for that.
Co-authored-by: Momo Kornher <mail@moritzkornher.de>
Pull request has been modified.
@Mergifyio update |
✅ Branch has been successfully updated |
@mrgrain Can you take another look? I've re-updated the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice the update in here to sharedMemorySize
. We can't actually do that because it's a breaking change.
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
Pull request has been modified.
cd1ee61
to
ac9c9ad
Compare
I updated the integration test snapshot with the new version and fulfilled your request on the parameter type. I think this is ready for approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for all your work on this!
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Add support to
MaxSwap
andSwappiness
attributes in theLinuxParameters
construct.Closes #18460
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license