hashicorp/nomad · error

error streaming previous alloc %q for new alloc %q: %s

Error message

error streaming previous alloc %q for new alloc %q: %s

What it means

When the tar stream contains the error snapshot file, the remote side errored while snapshotting its alloc dir. Nomad reads the message out of that file and returns it wrapped in this error, propagating the original remote failure (with prevAllocID and allocID for context).

Source

Thrown at client/allocwatcher/alloc_watcher.go:610

			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",
				p.prevAllocID, p.allocID, string(errBuf))
		}

		// If the header is for a directory we create the directory
		if hdr.Typeflag == tar.TypeDir {
			name := filepath.Join(dest, hdr.Name)
			os.MkdirAll(name, os.FileMode(hdr.Mode))

			// Can't change owner if not root or on Windows.
			if euid == 0 {
				if err := os.Chown(name, hdr.Uid, hdr.Gid); err != nil {
					return fmt.Errorf("error chowning directory %w", err)
				}
			}
			continue
		}
		// If the header is for a symlink we create the symlink
		if hdr.Typeflag == tar.TypeSymlink {

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Read the embedded %s message — it is the actual remote error; fix that underlying issue
  2. Check the previous node's client logs around the migration for the original snapshot failure
  3. Verify permissions and existence of files in the previous alloc dir
  4. Retry the allocation migration after resolving the remote-side issue
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure the previous alloc dir is intact and readable before migration:
// stat the data dir and confirm the client can snapshot it

Try / catch

if err := watcher.Wait(ctx); err != nil {
    // The embedded message is the true remote cause; surface it to operators
    log.Error("prev alloc migration failed on remote side", "cause", err)
    return err
}

Prevention

When it happens

Trigger: streamAllocDir sees a tar header for errorFilename, reads it successfully, and returns the embedded message string via fmt.Errorf with %s.

Common situations: Remote client failed to snapshot the previous alloc dir (permissions, files vanished mid-snapshot, disk errors); the surfaced message is actually the remote-side root cause.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/ad5f46b56a11abb8. Report an issue: GitHub.