Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion terraform/modules/container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ No modules.
| <a name="input_container_memory"></a> [container\_memory](#input\_container\_memory) | memory allocation in MB. 1024 is one full gig of memory | `number` | `1024` | no |
| <a name="input_container_memory_reservation"></a> [container\_memory\_reservation](#input\_container\_memory\_reservation) | Soft memory limit in MiB. ECS subtracts this from a container instance when placing the task; the container may burst above it up to `container_memory`, which stays the hard cap. EC2 launch type only. | `number` | `256` | no |
| <a name="input_container_port"></a> [container\_port](#input\_container\_port) | what port this container opens up to the outside | `number` | n/a | yes |
| <a name="input_deployment_maximum_percent"></a> [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | Ceiling on running tasks during a deploy. Defaults to 200. Values <= 100 are rejected by ECS when Availability Zone Rebalancing is enabled, which it is on this cluster. | `number` | `null` | no |
| <a name="input_deployment_maximum_percent"></a> [deployment\_maximum\_percent](#input\_deployment\_maximum\_percent) | Ceiling on running tasks during a deploy. Defaults to 200, which lets a deploy start the new task before stopping the old one. | `number` | `null` | no |
| <a name="input_deployment_minimum_healthy_percent"></a> [deployment\_minimum\_healthy\_percent](#input\_deployment\_minimum\_healthy\_percent) | Percent of the desired count that must stay running during a deploy. Leave null to derive from `environment`: 100 for prod, 0 everywhere else. | `number` | `null` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | n/a | `string` | n/a | yes |
| <a name="input_health_check_path"></a> [health\_check\_path](#input\_health\_check\_path) | path for load balancer health checks. This path should return HTTP 200 if the app is up. This path does not need to follow the prefix of `path`, it can be any path | `string` | `"/"` | no |
Expand Down
11 changes: 8 additions & 3 deletions terraform/modules/container/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ locals {
# second copy of the task's memory reservation. Non-prod may drop to zero, which lets a
# deploy proceed even when the host has no memory to spare.
deployment_min = var.deployment_minimum_healthy_percent != null ? var.deployment_minimum_healthy_percent : (var.environment == "prod" ? 100 : 0)
# max stays 200 everywhere: ECS Availability Zone Rebalancing rejects maximumPercent <= 100,
# so a non-prod 0/100 is refused at UpdateService. 0/200 still lets a deploy fall back to
# stop-then-start when the host has no spare memory, rather than deadlocking on placement.
# max stays 200 everywhere: prod needs it to start the new task before stopping the old,
# and non-prod's 0/200 still lets a deploy fall back to stop-then-start when the host has
# no spare memory, rather than deadlocking on placement.
deployment_max = var.deployment_maximum_percent != null ? var.deployment_maximum_percent : 200

# Memory is the scarce resource on the single host. Binpacking on it keeps tasks on as few
Expand Down Expand Up @@ -593,6 +593,11 @@ resource "aws_ecs_service" "fargate" {
deployment_minimum_healthy_percent = local.deployment_min
deployment_maximum_percent = local.deployment_max

# Off because the cluster is one host in one Availability Zone, so there is nothing to
# rebalance across. While it was on, ECS accepted only placement strategies that spread
# by Availability Zone and rejected the binpack below at UpdateService (#255).
availability_zone_rebalancing = "DISABLED"

dynamic "ordered_placement_strategy" {
for_each = local.placement_strategies
content {
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/container/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ variable "deployment_minimum_healthy_percent" {
}

variable "deployment_maximum_percent" {
description = "Ceiling on running tasks during a deploy. Defaults to 200. Values <= 100 are rejected by ECS when Availability Zone Rebalancing is enabled, which it is on this cluster."
description = "Ceiling on running tasks during a deploy. Defaults to 200, which lets a deploy start the new task before stopping the old one."
type = number
default = null
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/projects/home-unite-us/environment-prod.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module "prod_service" {
// run on -- the RDS instance is not involved despite what the abandoned Terragrunt
// state suggests. The task definition declares no volume and no mount, so this file
// is created empty on every task start and destroyed with the task. Application
// data therefore does not survive a deploy, a host drain or an AZ rebalance; the
// data therefore does not survive a deploy or a host drain; the
// log group shows 743 task generations. Reproduced here deliberately so the cutover
// changes nothing, and recorded so the next reader does not mistake it for working
// persistence. The absolute form is used because a relative URL would depend on the
Expand Down