{"record":{"id":"ad5f46b56a11abb8","repo":"hashicorp/nomad","slug":"error-streaming-previous-alloc-q-for-new-alloc-q-ad5f46","errorCode":null,"errorMessage":"error streaming previous alloc %q for new alloc %q: %s","messagePattern":"error streaming previous alloc %q for new alloc %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocwatcher/alloc_watcher.go","lineNumber":610,"sourceCode":"\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q: %w\",\n\t\t\t\tp.prevAllocID, p.allocID, err)\n\t\t}\n\n\t\tif escapes, err := escapingfs.PathEscapesAllocDir(dest, \"\", hdr.Name); err != nil {\n\t\t\treturn fmt.Errorf(\"error evaluating object: %w\", err)\n\t\t} else if escapes {\n\t\t\treturn fmt.Errorf(\"archive contains object that escapes alloc dir\")\n\t\t}\n\n\t\tif hdr.Name == errorFilename {\n\t\t\t// Error snapshotting on the remote side, try to read\n\t\t\t// the message out of the file and return it.\n\t\t\terrBuf := make([]byte, int(hdr.Size))\n\t\t\tif _, err := tr.Read(errBuf); err != nil && err != io.EOF {\n\t\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q; failed reading error message: %w\",\n\t\t\t\t\tp.prevAllocID, p.allocID, err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q: %s\",\n\t\t\t\tp.prevAllocID, p.allocID, string(errBuf))\n\t\t}\n\n\t\t// If the header is for a directory we create the directory\n\t\tif hdr.Typeflag == tar.TypeDir {\n\t\t\tname := filepath.Join(dest, hdr.Name)\n\t\t\tos.MkdirAll(name, os.FileMode(hdr.Mode))\n\n\t\t\t// Can't change owner if not root or on Windows.\n\t\t\tif euid == 0 {\n\t\t\t\tif err := os.Chown(name, hdr.Uid, hdr.Gid); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"error chowning directory %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// If the header is for a symlink we create the symlink\n\t\tif hdr.Typeflag == tar.TypeSymlink {","sourceCodeStart":592,"sourceCodeEnd":628,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocwatcher/alloc_watcher.go#L592-L628","documentation":"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).","triggerScenarios":"streamAllocDir sees a tar header for errorFilename, reads it successfully, and returns the embedded message string via fmt.Errorf with %s.","commonSituations":"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.","solutions":["Read the embedded %s message — it is the actual remote error; fix that underlying issue","Check the previous node's client logs around the migration for the original snapshot failure","Verify permissions and existence of files in the previous alloc dir","Retry the allocation migration after resolving the remote-side issue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the previous alloc dir is intact and readable before migration:\n// stat the data dir and confirm the client can snapshot it","typeGuard":null,"tryCatchPattern":"if err := watcher.Wait(ctx); err != nil {\n    // The embedded message is the true remote cause; surface it to operators\n    log.Error(\"prev alloc migration failed on remote side\", \"cause\", err)\n    return err\n}","preventionTips":["Verify file permissions and stability of the previous alloc dir before migration","Check remote client logs around snapshot time for the root cause","Avoid killing tasks on the previous node mid-snapshot"],"tags":["nomad","alloc-migration","tar-stream","remote-error"],"backgroundTag":"remote-snapshot-error-propagated","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}