{"record":{"id":"1e81de187ba13380","repo":"hashicorp/nomad","slug":"failed-to-snapshot-s-w","errorCode":null,"errorMessage":"failed to snapshot %s: %w","messagePattern":"failed to snapshot (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocdir/alloc_dir.go","lineNumber":269,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\t// Walk through all the top level directories and add the files and\n\t// directories in the archive\n\tfor _, path := range rootPaths {\n\t\tif err := filepath.Walk(path, walkFn); err != nil {\n\t\t\tallocID := filepath.Base(a.AllocDir)\n\t\t\tif writeErr := writeError(tw, allocID, err); writeErr != nil {\n\t\t\t\t// This could be bad; other side won't know\n\t\t\t\t// snapshotting failed. It could also just mean\n\t\t\t\t// the snapshotting side closed the connect\n\t\t\t\t// prematurely and won't try to use the tar\n\t\t\t\t// anyway.\n\t\t\t\ta.logger.Warn(\"snapshotting failed and unable to write error marker\", \"error\", writeErr)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"failed to snapshot %s: %w\", path, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Move other alloc directory's shared path and local dir to this alloc dir.\nfunc (a *AllocDir) Move(other Interface, tasks []*structs.Task) error {\n\ta.mu.RLock()\n\tif !a.built {\n\t\t// Enforce the invariant that Build is called before Move\n\t\ta.mu.RUnlock()\n\t\treturn fmt.Errorf(\"unable to move to %q - alloc dir is not built\", a.AllocDir)\n\t}\n\n\t// Moving is slow and only reads immutable fields, so unlock during heavy IO\n\ta.mu.RUnlock()\n","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocdir/alloc_dir.go#L251-L287","documentation":"AllocDir.Snapshot walks the allocation directory and writes each entry into a tar writer; if any individual entry fails during the walk, Snapshot aborts and returns this error identifying the offending path. Callers (server streaming a snapshot back for `nomad alloc fs`) surface it to the client, possibly after an in-band error marker on the stream fails too.","triggerScenarios":"Any per-entry failure while walking the alloc dir — unreadable directories (permissions), vanished files, symlink read failures — during `nomad alloc fs` snapshot or API snapshot calls.","commonSituations":"Tasks modifying/deleting files in the shared dir during snapshot; permission-restricted subdirectories; dying disks or quota-exceeded filesystems.","solutions":["Identify the failing path in the message and fix permissions or remove the problematic entry","Retry the snapshot when the task is idle","Stop/restart the task to quiesce writes then snapshot","Check disk health and free space"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := allocDir.Snapshot(w)\nvar pathErr string\nif err != nil { pathErr = err.Error() } // message includes failing path; fix perms or retry when idle","preventionTips":["Fix permissions reported for the failing path","Snapshot while tasks are idle","Monitor disk health and quotas on nodes"],"tags":["filesystem","snapshot","tar","permissions"],"backgroundTag":"snapshot-walk-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}