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

fix(stepfunctions-tasks): checking for task token in EcsRunTask containerOverrides causes memory explosion #15187

Merged
merged 4 commits into from
Jun 18, 2021
Merged

fix(stepfunctions-tasks): checking for task token in EcsRunTask containerOverrides causes memory explosion #15187

merged 4 commits into from
Jun 18, 2021

Conversation

dillon-odonovan
Copy link
Contributor

@dillon-odonovan dillon-odonovan commented Jun 18, 2021

EcsRunTask containerOverrides had references to the entire construct tree causing a large amount of recursion
when trying to validate that the task token was provided in the waitForTaskToken integration pattern. The only place for the task token to appear is in the environment of a containerOverride, so we should only check for it there.

I also updated the error to mention JsonPath instead of Context since Context is deprecated.

In addition to the unit tests, I packaged the library to dotnet and succesfully synthed the minimal reproduction.

thanks to @BenChaimberg for providing the suggested fix

fixes #15124


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

…ntainerOverrides environment

the runTask containerOverrides had references to the entire construct tree causing a large amount of recursion
when trying to validate that the task token was provided. the only place for the task token to appear is in the
environment of a containerOverride, so only check for it there

I also updated the error to mention JsonPath instead of Context since Context is deprecated

fixes #15124

in addition to the unit tests, I packaged the library to dotnet and succesfully synthed the reproduction mentioned in #15124

thanks to @BenChaimberg for providing the suggested fix
@gitpod-io
Copy link

gitpod-io bot commented Jun 18, 2021

@dillon-odonovan
Copy link
Contributor Author

dillon-odonovan commented Jun 18, 2021

Do we need to make the same change for run-ecs-task-base.ts? It's marked deprecated, but I believe the same issue exists there.

if (this.integrationPattern === sfn.ServiceIntegrationPattern.WAIT_FOR_TASK_TOKEN
&& !sfn.FieldUtils.containsTaskToken(props.containerOverrides)) {
throw new Error('Task Token is missing in containerOverrides (pass JsonPath.taskToken somewhere in containerOverrides)');
}

specifically mention in the error that the task token is expected in the environment property of at least one containerOverride
@BenChaimberg BenChaimberg self-assigned this Jun 18, 2021
@BenChaimberg BenChaimberg changed the title fix(stepfunctions-tasks): only check for task token in ECS runTask containerOverrides environment fix(stepfunctions-tasks): checking for task token in EcsRunTask containerOverrides causes memory explosion Jun 18, 2021
Copy link
Contributor

@BenChaimberg BenChaimberg left a comment

Choose a reason for hiding this comment

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

Thank you so much for your contribution and investigation! Just some small comments.

Do we need to make the same change for run-ecs-task-base.ts? It's marked deprecated, but I believe the same issue exists there.

Yes, please.

rename variable in containerOverride's map arrow function to mbe more clear
propagate the same change EcsRunTaskBase since the same defect can occur there
add the same tests for EcsrunTaskBase to catch future regression
update EcsRunTaskBase task token validation error message to be more accurate and align with the same error throw in runTask
@mergify mergify bot dismissed BenChaimberg’s stale review June 18, 2021 16:34

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jun 18, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit af53798 into aws:master Jun 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Jun 18, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 7540a1a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dillon-odonovan dillon-odonovan deleted the fix/run-ecs-task-check-only-container-override-env branch June 18, 2021 17:49
matthewsvu pushed a commit to matthewsvu/aws-cdk that referenced this pull request Jun 22, 2021
…inerOverrides causes memory explosion (aws#15187)

EcsRunTask containerOverrides had references to the entire construct tree causing a large amount of recursion
when trying to validate that the task token was provided in the waitForTaskToken integration pattern. The only place for the task token to appear is in the environment of a containerOverride, so we should only check for it there.

I also updated the error to mention JsonPath instead of Context since Context is deprecated.

In addition to the unit tests, I packaged the library to dotnet and succesfully synthed the minimal reproduction.

thanks to @BenChaimberg for providing the suggested fix

fixes aws#15124

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
…inerOverrides causes memory explosion (aws#15187)

EcsRunTask containerOverrides had references to the entire construct tree causing a large amount of recursion
when trying to validate that the task token was provided in the waitForTaskToken integration pattern. The only place for the task token to appear is in the environment of a containerOverride, so we should only check for it there.

I also updated the error to mention JsonPath instead of Context since Context is deprecated.

In addition to the unit tests, I packaged the library to dotnet and succesfully synthed the minimal reproduction.

thanks to @BenChaimberg for providing the suggested fix

fixes aws#15124

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(stepfunctions-tasks): checking for task token in EcsRunTask containerOverrides causes memory explosion
3 participants