Repository navigation
Conversation
This was referenced Oct 15, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
fix/928
branch
4 times, most recently
from
October 17, 2026 02:17
aad10a0 to
f064d2c
Compare
…p/start, fix the TTL-pause message (#928) - status: a non-running instance is rendered from EC2 data and tags (state, stopped since and why, TTL deadline, compute and cost so far, EBS accruing while stopped). No SSH or SSM. A running instance with no public IP uses SSM. - pkg/sshtarget: every ssh/scp client starts through one guard that refuses empty, loopback and unspecified hosts (destination, -J, scp operands). A gate fails the build on any ssh/scp exec elsewhere, wrappers included. - spored: durable compute checkpoint on the root volume, written every tick and first on shutdown. The compute-seconds tag flush is retried and logged. Each boot counts from kernel boot without double-counting a same-boot restart. A restarted instance's billed time excludes the stop. - stop/hibernate/start: say the TTL deadline still applies (local time with UTC). start no longer overwrites spawn:ttl. Help text and docs-gen agree, and that agreement is gated. - pkg/aws: InstanceInfo.StateReason (additive; api snapshot updated). (#928)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #928
Stacked on #916 (fix/896). Review and merge that first; this PR's base is
fix/896.1.
spawn statuson a stopped instance SSHed to localhostCause. status always took the SSH path. A stopped instance has no public IP, so the destination was
ec2-user@. ssh resolves an empty host to the local machine, so it reached the operator's own sshd (::1) and offered it their keys. Eleven call sites built a destination fromPublicIPwith no check.Fix.
runninginstance is asked. stopped, stopping, pending and other states are rendered from EC2 data and tags, with no SSH and no SSM:StateTransitionReason,StateReason)--output jsongives the same facts with"source": "ec2".--check-completeexits 3 (unknown) without connecting.pkg/sshtarget: every ssh/scp client starts throughsshtarget.Command. It parses the argv the way ssh(1) and scp(1) do and refuses an empty,localhost/*.localhost, loopback or unspecified host. That covers the destination, every-Jjump host and every scp remote operand, plus a host that would be read as an option. All 13 exec sites were moved to it (connect, status, config, extend, queue, plugin ×2, arraygroup, service upload ×2, pkg/service exec and tunnel).spawn extendon a stopped instance no longer tries to reach spored. Its failure hint used to suggestssh user@with no host.aws.InstanceInfo.StateReasonwas added (additive;make api-snapshotcommitted).2. Compute from earlier boots was dropped after a restart
Cause. The carry-over existed:
spawn:compute-secondsis read at boot and flushed inCleanupon SIGTERM. But it had three weaknesses:Fix.
/var/lib/spored/compute-checkpoint.json). The record holds instance id, boot_id, base, the boot's count start and total. It is written at daemon start, every tick, and first thing inCleanup, before any network call. The write is atomic and fsynced.resolveComputeStart):/proc/uptime, clamped to launch).3.
spawn stopsaid the TTL countdown pausesIt does not: the deadline is absolute (docs/safety: "It never moves across stop/wake cycles").
The TTL deadline still applies: 2026-10-15 11:42 MDT (18:42 UTC), in 59m. It keeps counting while the instance is stopped.start prints the same and says the stop did not extend it. If the deadline has already passed, the message says starting terminates the instance.spawn startprinted "Restoring TTL: … (was paused during stop)" and overwrotespawn:ttlwith the remaining time.pkg/ttldefines that tag as the total from launch, so the overwrite changed its meaning (and shortened the lifetime of pre-deadline-tag instances). stop no longer savesspawn:ttl-remaining, and start no longer writesspawn:ttl.docs-gen/) carry one shared statement. A gate scans every cmd/ string literal, plus docs-gen/, docs/ and README, for a TTL pause/resume claim, and requires the statement on the three reference pages. I checked the spore-host docs site by hand (safety.md, tools/spawn.md, go-library.md): they already agree that the deadline doesn't move.Tests
All tests are unit tests with fakes. No AWS resources were created and nothing was launched.
Each new test was watched failing against a revert that compiles (rule 1). The assertions come from the issue and the docs:
statusNeedsInstancereturns true for any stateTestStatus_OnlyARunningInstanceIsAskedTestCommand_RefusesTheStoppedInstanceArgvFromTheIssue(the issue's exact argv)TestCheckHostexec.Command("ssh")back in status.go (aliasedos/execimport too), and service.go'srunQuietlyback on raw execTestEverySSHExecGoesThroughTheGuard(AST scan of every non-test Go file, wrappers included; it fails if discovery finds nothing)TestResolveComputeStart_CarriesEarlierBootsAcrossAStop(issue timeline: first run + 22s, not 22s)CleanupTestCleanup_PersistsComputeWhenTheTagWriteFailsTestCleanup_PersistsComputeWhenTheTagWriteFailsTestStatusReport_RestartedInstanceDoesNotBillTheStopTestResolveComputeStart_FirstBootTestStopNotice_SaysTheDeadlineStillAppliesTestStopStartAgreeWithTheDocsThatTheDeadlineDoesNotPausestartTagswritesspawn:ttlTestStopStartDoNotTouchTheTTLTestStopStartAgreeWithTheDocsThatTheDeadlineDoesNotPauseAlso covered: same-boot restart doesn't count twice, tag-only upgrade path, foreign or unidentified checkpoint ignored, larger of tag and checkpoint wins, stopped JSON, past-due deadline, unknown compute shown as
—.make checkpasses exceptTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs a Docker daemon (not running locally).make check-nestedpasses (9 modules).GOOS=linuxandGOOS=windowsvet are clean.make gen-docsleaves no diff.Caveats
spawn upgrade-spored). The status-from-EC2 view, the ssh guard and the stop/start messages are CLI-side and work against any spored.After=network-online.targetin the unit.Follow-ups filed: #945 (hibernation), #946 (
TestSporedUnit_NoPrivateTmplists files and misses two units in cmd/app.go), spore-host/spore-host#554 (safety.md says--cost-limitis compute-only; spored enforces compute + EBS).