{"record":{"id":"9ecac081f9c1d399","repo":"hashicorp/nomad","slug":"insufficient-write-permissions-in-s-w","errorCode":null,"errorMessage":"insufficient write permissions in %s: %w","messagePattern":"insufficient write permissions in (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/raftutil/migrate.go","lineNumber":199,"sourceCode":"\nfunc preflightChecks(boltPath, walDir, raftDir string) error {\n\t// Verify the BoltDB file exists.\n\tboltInfo, err := os.Stat(boltPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"BoltDB store not found at %s: %w\", boltPath, err)\n\t}\n\n\t// Verify the WAL directory does not already exist.\n\tif _, err := os.Stat(walDir); err == nil {\n\t\treturn fmt.Errorf(\n\t\t\t\"WAL directory already exists at %s; remove it before retrying migration\",\n\t\t\twalDir)\n\t}\n\n\t// Check write permissions on raft directory.\n\ttestFile := filepath.Join(raftDir, \".permission-test\")\n\tif err := os.WriteFile(testFile, []byte(\"test\"), 0o600); err != nil {\n\t\treturn fmt.Errorf(\"insufficient write permissions in %s: %w\", raftDir, err)\n\t}\n\tos.Remove(testFile)\n\n\t// Check available disk space.\n\tusage, err := disk.Usage(raftDir)\n\tif err != nil {\n\t\t// Log warning but don't fail migration - disk space check is advisory.\n\t\treturn fmt.Errorf(\"unable to check available disk space: %w\", err)\n\t}\n\tavailableSpace := usage.Free\n\n\tboltSize := uint64(boltInfo.Size())\n\n\t// Require at least the BoltDB size + minimum free space buffer.\n\t// WAL format is typically similar in size to BoltDB, but we add a buffer.\n\trequiredSpace := boltSize + minRequiredSpace\n\tif availableSpace < requiredSpace {\n\t\treturn fmt.Errorf(","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/raftutil/migrate.go#L181-L217","documentation":"preflightChecks (raft-to-WAL migration) wraps the failure of writing a .permission-test probe file into the raft directory, proving the process lacks write permission on that directory before migration starts.","triggerScenarios":"Thrown at helper/raftutil/migrate.go:199 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Grant the user running the migration write access to the raft directory (chown/chmod)","Stop Nomad and run the migration as a user that owns the data directory","Verify the filesystem is not mounted read-only"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}