Skip to content

fix(autoscale): scope the coverage check to the env, and drop the space-valued param - #778

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/772-env-scoped-coverage
Oct 9, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/772-env-scoped-coverage

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Two defects, both found by actually deploying rather than by reading.

1. The coverage check warned about the wrong environment

It matched orchestrators by name prefix and took whichever the API returned
first. The moment staging's schedule was disabled, a user working in
production saw:

⚠️  the autoscale orchestrator spawn-autoscale-orchestrator-staging is deployed,
    but its schedule … is DISABLED

…about an environment they weren't using, while production's schedule was
healthy. A warning about the wrong thing is the #624 cry-wolf failure —
reintroduced by the check written to prevent it, one commit after I described
that exact risk.

Now an exact match on AutoscaleFunctionName(env) for the --env in use, and an
absent result names the function it looked for as well as the region.

Verified both ways live: production reports healthy; --env staging reports
DISABLED.

2. ScheduleRate can't be passed inline, and it failed a real deploy

--parameter-overrides cannot carry a value containing a space, and every
valid EventBridge rate has one. Passing 'ScheduleRate=rate(1 minute)' failed
the staging deploy:

Parameter ScheduleExpression is not valid. (Service: EventBridge, Status Code: 400)

and rolled the stack back. The ttl-reaper Makefile documents this trap at
length — "sam either rejects the line outright or, worse, silently falls through
to another pattern and mis-keys every parameter"
— and I passed one inline
anyway. It failed the better of the two ways.

Rollback verified complete, not assumed: stack parameters back to the
original two, rule still ENABLED at rate(1 minute), function Active, and
neither SPAWN_VERSION nor the spawn:version tag present — so env and tags
reverted too.

ScheduleRate is no longer passed; the template default is correct, and the
Makefile now says it must not be re-added without a file:// params file.

Also hardened

Deployed

Staging ScheduleState=DISABLED via a reviewed change set (the rule changed only
State and Targets; the role change was Tags-only). Production untouched and
still ENABLED
, confirmed after.

…ce-valued param

Two defects, both found by actually deploying rather than by reading.

## 1. The coverage check warned about the wrong environment

It matched orchestrators by NAME PREFIX and took whichever the API
returned first. The moment staging's schedule was disabled, a user
working in PRODUCTION saw:

  ⚠️ the autoscale orchestrator spawn-autoscale-orchestrator-staging is
     deployed, but its schedule … is DISABLED

about an environment they were not using, while production's schedule was
healthy. A warning about the wrong thing is the #624 cry-wolf failure —
reintroduced by the check written to prevent it, one commit after I
described that risk.

Now an EXACT match on AutoscaleFunctionName(env) for the --env being
operated on. An absent result names the function it looked for as well as
the region, so "not found" says what was missing instead of gesturing at
a category.

Verified both ways against the live account: production reports healthy,
--env staging reports DISABLED.

## 2. ScheduleRate could not be passed inline, and that failed a deploy

`--parameter-overrides` cannot carry a value containing a SPACE, and every
valid EventBridge rate has one. Passing 'ScheduleRate=rate(1 minute)'
failed the staging deploy with

  Parameter ScheduleExpression is not valid. (Service: EventBridge, 400)

and rolled the stack back. The ttl-reaper Makefile documents this trap at
length — "sam either rejects the line outright or, worse, silently falls
through to another pattern and mis-keys every parameter" — and I passed a
space-containing value inline anyway. It failed the better way of the two.

Rollback verified COMPLETE rather than assumed: stack params back to the
original two, rule still ENABLED at rate(1 minute), function Active, and
neither SPAWN_VERSION nor the spawn:version tag present — so env and tags
reverted too.

ScheduleRate is no longer passed. The template default is correct, and the
Makefile now says it must not be re-added without switching to a file://
params file.

## Also hardened while here

- `--region $(REGION)` is now explicit on the deploy. Without it a wrong
  ambient region does not fail — it CREATES A SECOND STACK elsewhere while
  the real one sits untouched.
- `EC2RoleArn` is passed explicitly. --parameter-overrides is not
  additive, so an omitted parameter resets to the template default; it was
  benign only because the live value and the default happen to agree,
  which is luck (#650).

Deployed: staging ScheduleState=DISABLED, via a reviewed change set.
Production untouched and still ENABLED, confirmed after.
@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/autoscalecoverage.go 54.54% 5 Missing ⚠️
cmd/autoscale_coverage.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 8695ba4 into main Oct 9, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/772-env-scoped-coverage branch October 9, 2026 20:29
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