Skip to content

Give --check stand-in nodes the real node type's capabilities - #99

Merged
bgrewell merged 1 commit into
mainfrom
feature/check-capabilities
Aug 8, 2026
Merged

Give --check stand-in nodes the real node type's capabilities#99
bgrewell merged 1 commit into
mainfrom
feature/check-capabilities

Conversation

@bgrewell

@bgrewell bgrewell commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Stacked on #98.

The problem

--check substituted a single mock for every declared node, and that mock's capability set matched no real node type — it was wrong in both directions:

  • It implemented Rebooter, so a suite rebooting a docker node validated clean and failed only on a real run, after the containers had been created.
  • It did not implement Snapshotter, so every suite containing a snapshot step was rejected outright — including on lxd, where the step is perfectly valid. That made --check unusable for any suite using snapshots.

The fix

Capabilities now live in one table in nodetypes, consulted by both the stand-in nodes and the supported: ... half of the construction-time error messages. NewCheckNode(nodeType) returns a stand-in implementing exactly what that type really implements.

Before / after, same two suites:

### snapshot on an lxd node — was wrongly REJECTED
Configuration valid.

### reboot on a docker node — was wrongly ACCEPTED
Error: node "web" does not support reboot (supported: lxd, lxd-vm, ssh) in step "restart it"

Note the message now includes lxd-vm, which the hardcoded (supported: lxd, ssh) strings had omitted — a third, smaller inaccuracy the table fixes by construction.

Drift guard

The table caused this bug by being implicit, so the replacement is tested rather than trusted. TestCapabilityTableMatchesNodeTypes compares the table against what each node type actually implements — using zero-value pointers, so interfaces are checked without constructing anything or touching a daemon — and fails if any type the factory accepts is missing from the test. TestCheckNodeMirrorsRealCapabilities asserts each stand-in matches its type.

A node type that gains or loses a capability without updating the table now fails the build rather than silently putting --check back out of step.

Verification

  • Both defect suites behave correctly, shown above.
  • Every standalone example suite still passes --check.
  • go build, go vet, gofmt, and the full test suite are green; the docs site builds.
  • Docs updated: the two Notes describing these limitations are gone, and the --check sections in the README, cli.md, and steps.md now describe what it actually does.

--check substituted one mock for every node, and that mock's capabilities
matched no real node type. It implemented reboot, so a suite rebooting a
docker node validated clean and failed only on a real run once the
containers existed. It did not implement snapshots, so every suite
containing a snapshot step was rejected outright, even on lxd where the
step is valid.

Capabilities now live in one table in nodetypes, consulted by both the
stand-in nodes and the "supported: ..." half of the construction-time
errors. A test asserts the table matches what each node type actually
implements, using zero-value pointers so no daemon is needed, and fails if a
known node type is missing from it — the drift that caused this.

The reboot messages gain lxd-vm, which the hardcoded lists had omitted.
Base automatically changed from feature/reject-unknown-options to main August 8, 2026 15:43
@bgrewell
bgrewell merged commit 05a8170 into main Aug 8, 2026
2 checks passed
@bgrewell
bgrewell deleted the feature/check-capabilities branch August 8, 2026 15:43
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