carlos / platform Public

region-host: capacity alarm comment: missing recovery sample still breaches

Astra R2 nit: only an observed non-breaching period breaks the 5/5
sequence. Test message says breaching periods, not minutes short.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev cae69350efc057b3ff54201374c563ae429df42a parent 3cb7614
2 files changed, +6 −4
  • infra/modules/region-host/group_alarms.tf +5 −3
  • infra/modules/region-host/tests/group_alarms.tftest.hcl +1 −1
diff --git a/infra/modules/region-host/group_alarms.tf b/infra/modules/region-host/group_alarms.tf
index 9d8e5f10d..606d6907b 100644
--- a/infra/modules/region-host/group_alarms.tf
+++ b/infra/modules/region-host/group_alarms.tf
@@ -40,9 +40,11 @@ locals {
# breaches when the group is short OR an ASG input is missing (FILL makes
# a late sample breach), so five periods mixing the two also alarm, and a
# late sample can delay the clear. A member that never comes back still
-# pages. A shortfall that clears within any five periods does not page
-# here; launch failures notify separately through the EventBridge rule
-# below (best effort, no added window).
+# pages. An observed non-breaching period (full membership reported)
+# breaks the sequence, so a dip that reports recovered within five
+# periods does not page here; a recovery whose sample is missing still
+# counts as breaching. Launch failures notify separately through the
+# EventBridge rule below (best effort, no added window).
resource "aws_cloudwatch_metric_alarm" "group_capacity" {
count = var.mode == "group" ? 1 : 0
alarm_name = "${var.name}-group-capacity"
diff --git a/infra/modules/region-host/tests/group_alarms.tftest.hcl b/infra/modules/region-host/tests/group_alarms.tftest.hcl
index 26ed6608f..06b1b8c9d 100644
--- a/infra/modules/region-host/tests/group_alarms.tftest.hcl
+++ b/infra/modules/region-host/tests/group_alarms.tftest.hcl
@@ -225,7 +225,7 @@ run "group_alarm_producers" {
}
assert {
condition = aws_cloudwatch_metric_alarm.group_capacity[0].threshold == 0 && aws_cloudwatch_metric_alarm.group_capacity[0].comparison_operator == "LessThanThreshold" && aws_cloudwatch_metric_alarm.group_capacity[0].evaluation_periods == 5 && aws_cloudwatch_metric_alarm.group_capacity[0].datapoints_to_alarm == 5 && one([for q in aws_cloudwatch_metric_alarm.group_capacity[0].metric_query : q.expression if q.id == "deficit"]) == "IF(FILL(desired, -1) < 0, -1, FILL(inservice, -1) - desired)" && alltrue([for q in aws_cloudwatch_metric_alarm.group_capacity[0].metric_query : length(q.metric) == 0 ? true : q.metric[0].period == 60 && q.metric[0].namespace == "AWS/AutoScaling" && q.metric[0].dimensions == tomap({ AutoScalingGroupName = aws_autoscaling_group.group[0].name })])
- error_message = "capacity uses actual desired membership including approved Standby, and alarms only after 5 of 5 minutes short"
+ error_message = "capacity uses actual desired membership including approved Standby, and alarms only after five consecutive breaching one-minute periods"
}
assert {
condition = aws_cloudwatch_metric_alarm.group_memory[0].metric_name == "MemAvailablePercent" && aws_cloudwatch_metric_alarm.group_memory[0].statistic == "Minimum" && aws_cloudwatch_metric_alarm.group_memory[0].period == 60 && aws_cloudwatch_metric_alarm.group_memory[0].threshold == 15 && aws_cloudwatch_metric_alarm.group_memory[0].evaluation_periods == 3 && aws_cloudwatch_metric_alarm.group_memory[0].datapoints_to_alarm == 3 && aws_cloudwatch_metric_alarm.group_memory[0].comparison_operator == "LessThanThreshold"