## TL;DR
Check the target before the restore, not during it: the test failed mid-way because nobody verified the datastore could hold the restored VM. Add a pre-flight that reads the target host's datastore free space, subtracts the restored VM's provisioned size with headroom for snapshots and growth, and refuses or re-targets the restore before any data moves. A mid-test power-on failure is the expensive way to learn arithmetic the pre-flight does for free.

```text
agent restored to a host without checking datastore free space and the VM failed to power on mid-test
```

## Use this when
- The job or restore fails with this symptom: agent restored to a host without checking datastore free space and the VM failed to power on mid-test.
- You are working on an agent running restore tests onto hypervisor hosts and the failure repeats on the same target or schedule.
- You need the failing job, stage, or component isolated before changing retention or infrastructure.

## Not for this skill when
- A thin-provisioned VM whose real consumption is far below its provisioned size, where the pre-flight should use measured consumption with headroom instead.
- The error text names a different product, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Compute the restored VM's space need from its disks and compare with the target datastore's free space. Verify: the space equation is explicit
2. Add the pre-flight check to the restore workflow with a stated headroom factor and a refusal path. Verify: under-resourced restores stop before starting
3. On refusal, select the next suitable host automatically or escalate with the numbers attached. Verify: the test re-targets or escalates cleanly
4. Run a restore test and confirm the pre-flight passes and the VM powers on and stays on. Verify: the full test completes
5. Log pre-flight numbers with each test so capacity trends are visible over time. Verify: capacity data accumulates with the test record

## Variant phrasings
### agent restore no datastore free space check vm failed power on
The verbatim phrasing.
### agent restore test preflight datastore space headroom fix
The pre-flight phrasing.
### restore test failed mid test datastore full agent check first
The mid-test phrasing.

Compatibility: Agent pre-flight checks for restore tests on hypervisor hosts

## Why it happens
Restores consume real storage the moment they run, and a datastore's free space is knowable to the byte beforehand. Agents that skip the check convert a planning question into a mid-operation failure that can also pressure the production VMs sharing that datastore.

## Edge cases / pitfalls
- Snapshots taken during the test and memory swap files add to consumption beyond the disk sizes; the headroom must cover them.
- A datastore can fill between the check and the restore in a busy environment; re-check at restore start.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_woApVAwOFqxJfMtiyQJJow
