Skip to content

Default the health check to EC2, and say when to promote it - #54

Merged
sethbergman merged 1 commit into
mainfrom
fix/asg-health-check-until-ansible
Aug 29, 2026
Merged

Default the health check to EC2, and say when to promote it#54
sethbergman merged 1 commit into
mainfrom
fix/asg-health-check-until-ansible

Conversation

@sethbergman

Copy link
Copy Markdown
Owner

A bare terraform apply of this profile never converged.

The loop

The group used health_check_type = "ELB". The profile deliberately does not issue TLS certificates — user-data says so and defers to Ansible — and Vault will not start without them, so the load balancer's check could never pass.

Every instance was marked unhealthy at the end of its grace period, terminated, and replaced by one that repeated it. Billing EC2, NAT and EBS throughout, and presenting as a slow bootstrap rather than a configuration gap.

The fix

health_check_type is now a variable defaulting to EC2. EC2 health only asks whether the instance is running — exactly enough for the window before Ansible has converged, and no more.

It is a variable rather than a flat change because the original reasoning was right: a cluster left on EC2 health forever cannot notice a node that is up but sealed, wedged, or out of quorum. docs/deployment.md now sequences the promotion right after the certificates it depends on:

terraform apply -var health_check_type=ELB

The test was holding the defect in place

The old assertion was health_check_type == "ELB" — so a value that made the apply loop forever was defended by a passing test. That is the same shape as every other bug found in this repo: a check that agrees with the thing it is supposed to question.

It now asserts both halves — the default is EC2 so the apply terminates, and ELB is reachable so the promotion is possible. The second block also asserts the target group still accepts a standby's 429, because promoting to ELB health is pointless if it then ejects healthy standbys.

Verified

Run in WSL rather than assumed:

  • terraform fmt -check -recursive clean
  • terraform test28 passed, 0 failed across the AWS suite
  • Mutation: reverting the default to ELB fails health_check_defaults_to_ec2_so_a_bare_apply_terminates and nothing else — 10 passed, 1 failed

🤖 Generated with Claude Code

A bare `terraform apply` of this profile never converged.

The group used health_check_type = "ELB". But the profile deliberately
does not issue TLS certificates -- user-data says so and defers to the
Ansible layer -- and Vault will not start without them, so the load
balancer's check could never pass. Every instance was therefore marked
unhealthy at the end of its grace period, terminated, and replaced by
one that repeated it: a loop, billing EC2, NAT and EBS throughout, and
presenting as a slow bootstrap rather than a configuration gap.

EC2 health only asks whether the instance is running, which is exactly
enough for the window before Ansible has converged and no more. It is now
the default, and health_check_type is a variable so the profile is not
trapped there -- a cluster left on EC2 health forever cannot notice a node
that is up but sealed or wedged, which is the reason ELB was chosen
originally and is still the right setting once Vault is serving.

The old test asserted the value was "ELB", which is how a defect that
makes the apply loop was held in place by a passing test. It now asserts
both halves: that the default is EC2, so the apply terminates, and that
ELB is reachable, so the promotion is possible. Reintroducing the "ELB"
default turns the first red while the second still passes.

docs/deployment.md sequences the promotion after the playbook converges,
next to the certificates it depends on.

Verified in WSL: terraform fmt clean, 28 assertions pass across the AWS
suite, and the mutation above fails exactly one of them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sethbergman
sethbergman merged commit 59a7833 into main Aug 29, 2026
27 checks passed
@sethbergman
sethbergman deleted the fix/asg-health-check-until-ansible branch August 29, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant