Skip to content

fsx: stop panicking on a CREATING filesystem; quote the PERSISTENT_2 storage rate - #627

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/618-619-fsx-panic-and-rate
Oct 1, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/618-619-fsx-panic-and-rate

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Refs #618, #619. Both were found while implementing #613's visibility fixes (#617), which had to route around #618 rather than change shared behaviour.

#618 — GetFSxFilesystem panicked on a provisioning filesystem

pkg/aws/fsx.go dereferenced three optional fields unconditionally:

DNSName:         *fs.DNSName,                       // nil while CREATING
MountName:       *fs.LustreConfiguration.MountName, // LustreConfiguration is nil while CREATING
StorageCapacity: *fs.StorageCapacity,

A filesystem in CREATING has no DNSName and no LustreConfiguration at all, so this was a nil-pointer panic rather than an error return — on a code path otherwise about to do real work. The tag scan had the same shape (*tag.Key / *tag.Value are both optional).

CREATING is not an edge case. FSx Lustre takes minutes to provision, and #613's reporter terminated their instance while the filesystem was still CREATING — the exact window. Reachable from cmd/launch_single.go:540 and cmd/task.go:966.

Verified, not assumed. I reintroduced the old derefs and ran the new test:

--- FAIL: TestFSxInfoFromCreatingFilesystem
panic: runtime error: invalid memory address or nil pointer dereference

Fixed, it passes. The mapping is extracted as a pure fsxInfoFrom(types.FileSystem) so it can be exercised against any lifecycle state without AWS — the existing tests here go through Substrate, which won't reliably reproduce a half-populated CREATING filesystem.

Empty DNSName/MountName is the meaningful result: a mount can't be constructed without them, so a not-ready filesystem reports as such instead of crashing the CLI.

#619 — fsx info quoted a PERSISTENT_1 rate

costPerMonth := float64(*fs.StorageCapacity) * 0.22 // $0.22/GB-month for SSD

$0.22/GiB-month is a PERSISTENT_1 figure. Every filesystem spawn creates is PERSISTENT_2, whose us-east-1 rate at the default 125 MB/s/TiB tier is $0.145 — and PERSISTENT_2 folds the throughput tier into the per-GiB price, so there is no single correct constant across tiers.

1200 GiB (the FSx Lustre minimum)
fsx info before ~$264/month
actual, PERSISTENT_2 @ 125 ~$174/month

~52% high. And since #617 taught --estimate-only to quote storage cost, two spawn commands disagreed about the same filesystem — which is worse than the previous silence, because a user reconciling against a real bill concludes the tool is guessing.

It now reads the actual throughput tier off the filesystem and calls the single shared fsxLustreMonthlyUSD from cmd/fsx_cost.go, labels the figure approximate with its region, and prints "unknown (storage capacity not reported yet)" rather than $0.00 when capacity isn't populated — the same CREATING case as #618.

Tests

pkg/aws/fsx_info_test.go — CREATING (panics pre-fix), nil tag Key/Value, and a fully-populated AVAILABLE filesystem so making the nil case safe can't have broken the normal one.

cmd/fsx_rate_consistency_test.go — two gates, following the fsx_promise_gate_test.go precedent from #617:

  • single source: fails if any file in cmd/ names an FSx rate in code (comments are stripped, so prose explaining why 0.22 was wrong stays legal). Proven by reintroducing 0.22 into fsx.go, which fails the gate.
  • right source: pins fsxLustreUSDPerGiBMonth(125) == 0.145 and the 1200 GiB floor at ~$174, so "one source" can't be satisfied by centralising the wrong rate.

That second gate matters because the first one alone would have been happy with 0.22 as long as it lived in one file.

Gates

gofmt clean · go vet ./... clean · go build ./... clean · go test ./... all green · make check-docs clean · staticcheck ./... 61 on main, 61 here, zero added (diffed).

Suggested bump: PATCH — a crash fix and a corrected number, no flag or behaviour change.

…NT_2 storage rate

#618: GetFSxFilesystem dereferenced DNSName, LustreConfiguration.MountName and
StorageCapacity unconditionally. All three are optional in the API and a
filesystem still CREATING has no DNSName and no LustreConfiguration at all, so
reaching this during provisioning panicked instead of returning something
usable — and CREATING is the exact window spawn#613 was reported from. The tag
scan had the same shape (Tag.Key/Value are both optional).

The mapping is extracted as a pure fsxInfoFrom so it can be tested against any
lifecycle state without AWS; the new test panics against the pre-fix code. Empty
DNSName/MountName is the meaningful answer — a mount cannot be built without
them, so 'not ready' is reported rather than crashing.

#619: fsx info multiplied capacity by a hardcoded 0.22, commented '$0.22/GB-month
for SSD'. That is a PERSISTENT_1 rate applied to filesystems spawn creates as
PERSISTENT_2, whose rate at the default 125 MB/s/TiB tier is $0.145 — overstating
a 1200 GiB filesystem by ~52% ($264 vs $174). Since #617 made --estimate-only
quote storage cost, two spawn commands disagreed about the same filesystem.

It now reads the actual throughput tier off the filesystem and uses the single
shared rate table in cmd/fsx_cost.go (fsxLustreMonthlyUSD), with both derefs
guarded for the same CREATING case. A drift gate fails if any file in cmd/ names
an FSx rate in code again, and pins the rate to the PERSISTENT_2 values so
'one source' cannot be satisfied by centralising the wrong number.

Refs #618, #619
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.16667% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/fsx.go 0.00% 10 Missing ⚠️
pkg/aws/fsx.go 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 52ea114 into main Oct 1, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/618-619-fsx-panic-and-rate branch October 1, 2026 05:21
scttfrdmn added a commit that referenced this pull request Oct 1, 2026
Promote Unreleased to [0.112.1] and update compare links.

Also adds the CHANGELOG entries for #618/#619, which PR #627 shipped without —
CLAUDE.md requires the changelog in the same PR as the change, and that was
missed. Recording it here rather than leaving the release unexplained.

PATCH: a crash fix and a corrected cost figure; no flag, schema or behaviour
change.
scttfrdmn added a commit that referenced this pull request Oct 3, 2026
Third attempt at the presence half, and the first that actually runs.

Attempt 1: 'git diff base...HEAD' at fetch depth 1 — died with 'no merge base'
(exit 128) before reaching any logic, which would have failed EVERY pull request.

Attempt 2: deepen main to 100 commits — still no merge base, because the PR branch
is itself fetched at depth 1, so no shared object exists locally. The gate then took
its warn-and-skip fail-safe on every run. That is the worse outcome: it reads as
enforcement while enforcing nothing, which is exactly the defect #624 fixed in the
reaper-coverage check.

Attempt 3: 'gh api repos/{repo}/pulls/{n}/files'. GitHub already knows what the PR
changed; no history needed, nothing to go shallow. All context still arrives via env,
so there is no '${{ }}' in the script body and Semgrep's run-shell-injection rule
stays satisfied.

Validated against three real PRs rather than reasoned about:
  #638 (this one: test + CI + docs)     -> SKIP, correct
  #636 (4 non-test .go + CHANGELOG.md)  -> PASS
  #627 (2 non-test .go, no changelog)   -> FAIL, the PR that prompted all of this

The API-failure and empty-result paths still warn and pass: a gate must fail on a
known violation, not on its own inability to measure one.
scttfrdmn added a commit that referenced this pull request Oct 3, 2026
* ci: enforce the changelog policy instead of trusting habit

CLAUDE.md requires a CHANGELOG entry under [Unreleased] in the SAME PR as any
user-facing change, and the release ritual promotes that section verbatim. Nothing
checked either half, and both broke within a week.

#627 merged with no entry at all. It surfaced at the next release, which hit an EMPTY
[Unreleased] and had to reconstruct the entries from the diff at tag time — precisely
when you least want to be reverse-engineering what a change did.

Separately, three PRs each inserted their own '### Added' at the top of [Unreleased].
That merges cleanly for git and badly for Keep a Changelog: the section ended up with
duplicate '### Added' and '### Fixed' headings, consolidated by hand at release time.
Then it happened a second time.

Two halves, because they need different things:

- changelog_test.go (plain Go test, runs on push and locally): [Unreleased] has no
  duplicate groups, no unknown group names, no entries outside a group; and every
  single-version release heading has a compare link.
- A CI step (PR-only, since it needs the base branch): a PR that changes non-test Go
  source must touch CHANGELOG.md. Test-only, CI-only and docs-gen-only changes are
  exempt — there is nothing user-facing to describe — and the failure message says
  what to write and why the gate exists.

Format checks are scoped to [Unreleased] deliberately. Run over the whole file they
report duplicate groups in roughly a dozen SHIPPED releases and two invented group
names ('### CI', '### Changed (internal refactors — no behavior change)'). Gating
frozen history would force either a mass rewrite of released notes or a permanently
red test, and a permanently red test gets disabled — worse than no test. The job is to
stop new occurrences in the one section still being edited, which is also the only
place the problem creates work.

The compare-link check skips range headings like '[0.36.0 – 0.36.13]', which
summarise a span and have no single diff to point at; demanding a link there would be
a false positive that teaches people to ignore the test.

Each check was verified to fail on the real mistake it describes, and CLAUDE.md now
says the policy is enforced rather than advisory.

* fix(ci): the changelog gate had two bugs of its own

1. Shell injection. '${{ github.base_ref }}' interpolated into a run: block is a
   script-injection vector, and Semgrep's run-shell-injection rule blocked the PR —
   correctly. It is now passed via env: and referenced as $BASE_REF, with nothing from
   the github context in the script body.

2. It would have failed EVERY pull request. 'git diff base...HEAD' needs a merge base,
   the checkout is shallow, and a depth-1 fetch has no common ancestor — so the step
   died with 'fatal: origin/main...HEAD: no merge base' (exit 128) before any of the
   logic ran. Not a false positive: a total block on all work, shipped in CI. Caught
   on this PR's own first run.

   Now it deepens the fetch, resolves the merge base explicitly, and diffs from it, so
   the unresolvable case is detectable rather than fatal. When the merge base cannot be
   found (long-lived branch, force-pushed base) it WARNS and passes: a gate must fail
   on a known violation, not on its own inability to measure one.

Both paths verified locally — the normal case computes the right file list and
verdict, and a disconnected history warns and exits 0.

* fix(ci): ask the API what the PR changed, not a shallow clone

Third attempt at the presence half, and the first that actually runs.

Attempt 1: 'git diff base...HEAD' at fetch depth 1 — died with 'no merge base'
(exit 128) before reaching any logic, which would have failed EVERY pull request.

Attempt 2: deepen main to 100 commits — still no merge base, because the PR branch
is itself fetched at depth 1, so no shared object exists locally. The gate then took
its warn-and-skip fail-safe on every run. That is the worse outcome: it reads as
enforcement while enforcing nothing, which is exactly the defect #624 fixed in the
reaper-coverage check.

Attempt 3: 'gh api repos/{repo}/pulls/{n}/files'. GitHub already knows what the PR
changed; no history needed, nothing to go shallow. All context still arrives via env,
so there is no '${{ }}' in the script body and Semgrep's run-shell-injection rule
stays satisfied.

Validated against three real PRs rather than reasoned about:
  #638 (this one: test + CI + docs)     -> SKIP, correct
  #636 (4 non-test .go + CHANGELOG.md)  -> PASS
  #627 (2 non-test .go, no changelog)   -> FAIL, the PR that prompted all of this

The API-failure and empty-result paths still warn and pass: a gate must fail on a
known violation, not on its own inability to measure one.
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