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

@aws-cdk/aws-ecs-patterns: Add ability to set healthCheck for NetworkLoadBalancedFargateService #20233

Closed
1 of 2 tasks
samratjha96 opened this issue May 5, 2022 · 5 comments
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. wontfix We have determined that we will not resolve the issue.

Comments

@samratjha96
Copy link

Describe the feature

The QueueProcessingFargateService pattern provides the capability to supply a container health check directly as a prop. Would be great to have a similar prop for NetworkLoadBalancedFargateService so we can define container level health checks without needing to reconstruct the whole task definition from scratch:

Corresponding issue where it was added to QueueProcessingFargateService: #15636

Use Case

Need to add a healthcheck to ensure tasks are healthy and can be scheduled and run by ECS. The pattern construct doesn't allow passing one in forcing all tasks to always report HealthStatus: Unknown

Proposed Solution

Exactly the same as one applied here #18219 but in the NetworkLoadBalancedFargateService pattern:

const container = this.taskDefinition.addContainer(containerName, {

const container = this.taskDefinition.addContainer(containerName, {
        image: taskImageOptions.image,
        logging: logDriver,
        environment: taskImageOptions.environment,
        secrets: taskImageOptions.secrets,
        dockerLabels: taskImageOptions.dockerLabels,
        _healthCheck: props.healthCheck_
      });

Other Information

Using escape hatch:

// @ts-ignore
service.taskDefinition.defaultContainer!.props.healthCheck = <ecs.HealthCheck>{
    command: ['CMD-SHELL', 'wget localhost:5000'],
    interval: cdk.Duration.seconds(15),
    retries: 3,
    timeout: cdk.Duration.seconds(5),
};

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

1.153.0 (build 7d90993)

Environment details (OS name and version, etc.)

MacOS Monterrey 12.3.1

@samratjha96 samratjha96 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 5, 2022
@github-actions github-actions bot added the @aws-cdk/aws-ecs-patterns Related to ecs-patterns library label May 5, 2022
samratjha96 pushed a commit to samratjha96/aws-cdk that referenced this issue May 6, 2022
exposes a healthcheck prop in the NetworkLoadBalancedFargateService ecs pattern
that is passed through to the underlying TaskDefinition resource. Allows users
to specify a custom health check for the Fargate containers

fixes: aws#20233
samratjha96 pushed a commit to samratjha96/aws-cdk that referenced this issue May 6, 2022
exposes a healthcheck prop in the NetworkLoadBalancedFargateService ecs pattern
that is passed through to the underlying TaskDefinition resource. Allows users
to specify a custom health check for the Fargate containers

fixes: aws#20233
samratjha96 pushed a commit to samratjha96/aws-cdk that referenced this issue May 9, 2022
exposes a healthcheck prop in the NetworkLoadBalancedFargateService ecs pattern
that is passed through to the underlying TaskDefinition resource. Allows users
to specify a custom health check for the Fargate containers

fixes: aws#20233
@ahmetipkin
Copy link

Saw the issue yesterday myself too! How do we +1 :)

@peterwoodworth peterwoodworth added good first issue Related to contributions. See CONTRIBUTING.md p2 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jun 10, 2022
@peterwoodworth
Copy link
Contributor

We accept contributions and would be happy to review a PR for this!

@corymhall
Copy link
Contributor

pasting my response on the linked PR

After thinking about this more, I'm not sure we should expose this on the top level props. For an ECS service there behind a load balancer there are two different types of health checks that you can use.

  • ELB health checks (configured on the NLB in this case). The NLB will make a request to the service on a specific path/port and expect a certain response.
  • Container health checks (what this PR exposes). The service itself can perform health checks against the running containers (in addition to the ELB health checks).

I'm not sure this is a common use case for services running behind an ELB. The other linked PR that implemented this for the QueueProcessing service makes more sense because it is a worker service that is not running behind an ELB so container health checks are the only type of health check available.

I think in the majority of cases the user wants to configure the ELB health check and exposing this at the top level (an not the elb health check) would lead to more confusion and users configuring container health checks when they don't need to.

cc @madeline-k for a second opinion.

I'll leave this open for a little while for comments.

@corymhall corymhall added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. wontfix We have determined that we will not resolve the issue. labels Aug 3, 2022
@github-actions
Copy link

github-actions bot commented Aug 5, 2022

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 5, 2022
@josechifflet
Copy link

Any updates ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. wontfix We have determined that we will not resolve the issue.
Projects
None yet
6 participants