From 83424749eb4c1e68adc03843deb87fbae898c0a0 Mon Sep 17 00:00:00 2001 From: Jordan Stephens Date: Tue, 17 Sep 2024 11:39:28 -0700 Subject: [PATCH 1/2] adding an FAQ section to describe solutions to the invalid healthcheck error --- docs/faq.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index 36321b09c..f82b3548d 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -144,3 +144,31 @@ secrets: ### "Stack:… is in UPDATE_COMPLETE_CLEANUP_IN_PROGRESS state and cannot be updated" - This happens if different version of the Defang CLI are used with the same AWS account. Each version one will try to update the CD stack to its version, back and forth. Make sure that all users have the same version of the CLI. Check the CLI version using `defang version`. + +### "invalid healthcheck: ingress ports require an HTTP healthcheck on `localhost`. + +- This message is displayed when `defang compose up` tries to deploy a service with an "ingress" port, if the service does not have a `healthcheck` which mentions `localhost`. Defang routes a load balancer to your service's ingress ports, and the loadbalancer needs to be able to check the health of the service. Two solve this issue, ask yourself these two questions: + +1. Should my service be public? It's common to declare your container's ports using the Compose file "shorthand" syntax (`1234:1234`). This syntax can be understood as `[HOST:]CONTAINER`. If your service is not intended to be public, you do not need to declare a HOST port. For example: + + ```diff + services: + my-service: + image: my-image + ports: + - - "1234:1234" + + - "1234" + ``` +2. Does my healthcheck include the string `localhost`? It is very common to define a healthcheck by using `curl` or `wget` to make a request to `localhost`. So common, in fact, that defang will look for the string `localhost` in your healthcheck definition. For example, this healthcheck is valid: + + ```yaml + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:1234/health"] + ``` + + This healthcheck is not valid: + + ```yaml + healthcheck: + test: ["CMD", "./my-healthcheck"] + ``` From 282659eada38cf13119527b963526e118fcdd46e Mon Sep 17 00:00:00 2001 From: Jordan Stephens Date: Wed, 18 Sep 2024 12:34:02 -0700 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lio李歐 --- docs/faq.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index f82b3548d..0819e5efc 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -147,7 +147,7 @@ secrets: ### "invalid healthcheck: ingress ports require an HTTP healthcheck on `localhost`. -- This message is displayed when `defang compose up` tries to deploy a service with an "ingress" port, if the service does not have a `healthcheck` which mentions `localhost`. Defang routes a load balancer to your service's ingress ports, and the loadbalancer needs to be able to check the health of the service. Two solve this issue, ask yourself these two questions: +- This message is displayed when `defang compose up` tries to deploy a service with an "ingress" port, if the service does not have a `healthcheck` which mentions `localhost`. Defang routes a load balancer to your service's ingress ports, and the loadbalancer needs to be able to check the health of the service. To solve this issue, ask yourself these two questions: 1. Should my service be public? It's common to declare your container's ports using the Compose file "shorthand" syntax (`1234:1234`). This syntax can be understood as `[HOST:]CONTAINER`. If your service is not intended to be public, you do not need to declare a HOST port. For example: @@ -166,7 +166,7 @@ secrets: test: ["CMD", "curl", "-f", "http://localhost:1234/health"] ``` - This healthcheck is not valid: + This healthcheck is not valid for `ingress` ports: ```yaml healthcheck: