hashicorp/nomad · error
error streaming previous alloc %q for new alloc %q: %w
Error message
error streaming previous alloc %q for new alloc %q: %w
What it means
streamAllocDir reads the tar snapshot of the previous allocation directory from the HTTP response body, extracting each entry. If the tar reader or body read returns a non-EOF error mid-stream, the error is wrapped as 'error streaming previous alloc %q for new alloc %q: %w'. This means the snapshot transfer broke partway through, not that it failed to start.
Source
Thrown at client/allocwatcher/alloc_watcher.go:592
return false
}
}
// if we see this file, there was an error on the remote side
errorFilename := allocdir.SnapshotErrorFilename(p.prevAllocID)
buf := make([]byte, 1024)
for !canceled() {
// Get the next header
hdr, err := tr.Next()
// Snapshot has ended
if err == io.EOF {
return nil
}
if err != nil {
return fmt.Errorf("error streaming previous alloc %q for new alloc %q: %w",
p.prevAllocID, p.allocID, err)
}
if escapes, err := escapingfs.PathEscapesAllocDir(dest, "", hdr.Name); err != nil {
return fmt.Errorf("error evaluating object: %w", err)
} else if escapes {
return fmt.Errorf("archive contains object that escapes alloc dir")
}
if hdr.Name == errorFilename {
// Error snapshotting on the remote side, try to read
// the message out of the file and return it.
errBuf := make([]byte, int(hdr.Size))
if _, err := tr.Read(errBuf); err != nil && err != io.EOF {
return fmt.Errorf("error streaming previous alloc %q for new alloc %q; failed reading error message: %w",
p.prevAllocID, p.allocID, err)
}
return fmt.Errorf("error streaming previous alloc %q for new alloc %q: %s",View on GitHub (pinned to 482b49bf1a)
Solutions
- Check network stability between the two client nodes (packet loss, conntrack/proxy timeouts); retry the allocation so migration restarts
- Inspect the previous node's agent logs for snapshot-side errors during the transfer window
- Avoid draining/restarting the source node while its allocations are migrating
- Retry migration during lower network load or reduce alloc dir size (large task logs/data) to shorten the transfer
Defensive patterns
Strategy: retry
Try / catch
err := p.streamAllocDir(ctx, resp, allocDirPath)
if err != nil && !errors.Is(err, io.EOF) {
if strings.Contains(err.Error(), "error streaming previous alloc") {
// transfer broke mid-stream: safe to retry migration from scratch
}
return err
} Prevention
- Keep alloc dirs small (rotate/limit task logs) so snapshot transfers finish quickly
- Use stable, low-latency network links between client nodes; tune LB/proxy idle timeouts for long streams
- Never drain or kill the source agent during an in-progress migration
- Retry failed migrations — the operation is restartable since the prev alloc dir is rebuilt
When it happens
Trigger: During extraction loop, reading the next tar header or entry data returns an error other than io.EOF: the HTTP response body is truncated (connection reset mid-transfer), the remote node errors while reading the snapshot stream, gzip corruption, or a malformed/incomplete tar payload.
Common situations: Network interruption between nodes during a large allocation migration; previous node's agent crashes or is drained mid-stream; load balancer/proxy idle-timeout cutting a long-lived response; disk errors on the source node while snapshotting.
Related errors
- error getting snapshot from previous alloc %q: %w
- archive contains object that escapes alloc dir
- error streaming previous alloc %q for new alloc %q; failed r
- network namespace already exists but was misconfigured
- network already configured but not found in state
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/a51ccca21d43c5f1.
Report an issue: GitHub.