{"record":{"id":"83ad458ec73ef4d4","repo":"thanos-io/thanos","slug":"create-dir-83ad45","errorCode":null,"errorMessage":"create dir","messagePattern":"create dir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/bucket.go","lineNumber":700,"sourceCode":"\tfor _, option := range options {\n\t\toption(s)\n\t}\n\n\t// Depend on the options\n\tindexReaderPoolMetrics := indexheader.NewReaderPoolMetrics(extprom.WrapRegistererWithPrefix(\"thanos_bucket_store_\", s.reg))\n\ts.indexReaderPool = indexheader.NewReaderPool(s.logger, lazyIndexReaderEnabled, lazyIndexReaderIdleTimeout, indexReaderPoolMetrics, s.indexHeaderLazyDownloadStrategy)\n\ts.metrics = newBucketStoreMetrics(s.reg) // TODO(metalmatze): Might be possible via Option too\n\n\tif err := s.validate(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"validate config\")\n\t}\n\n\tif dir == \"\" {\n\t\treturn s, nil\n\t}\n\n\tif err := os.MkdirAll(dir, 0750); err != nil {\n\t\treturn nil, errors.Wrap(err, \"create dir\")\n\t}\n\n\treturn s, nil\n}\n\n// Close the store.\nfunc (s *BucketStore) Close() (err error) {\n\ts.mtx.Lock()\n\tdefer s.mtx.Unlock()\n\n\tfor _, b := range s.blocks {\n\t\trunutil.CloseWithErrCapture(&err, b, \"closing Bucket Block\")\n\t}\n\n\ts.indexReaderPool.Close()\n\treturn err\n}\n","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/bucket.go#L682-L718","documentation":"Returned by NewBucketStore when os.MkdirAll(dir, 0750) fails while creating the local block cache directory. The error is wrapped as \"create dir: <cause>\", so the cause is typically a permission problem, a read-only filesystem, or a path whose parent is a file.","triggerScenarios":"NewBucketStore called with a data directory that cannot be created: parent directory not writable, path component exists as a regular file, disk full, or container running as non-root without volume permissions.","commonSituations":"Kubernetes pods with readOnlyRootFilesystem and no emptyDir mounted at the store dir, wrong ownership on a hostPath volume, or a typo making the dir path collide with an existing file.","solutions":["Check that the parent of dir exists and is writable by the process user (ls -ld, id).","Ensure the directory path does not collide with an existing file; fix the path or remove the file.","In Kubernetes, mount an emptyDir/PVC at the store data directory and disable read-only root filesystem.","Verify free disk space and filesystem mount options (ro vs rw)."],"exampleFix":"// before\ndir := \"/var/thanos/store\" // may not exist or not be writable\n// after\ndir := \"/var/thanos/store\"\nif err := os.MkdirAll(dir, 0750); err != nil {\n    return errors.Wrapf(err, \"cannot create store dir %s (check permissions/volume mounts)\", dir)\n}","handlingStrategy":"validation","validationCode":"func ensureDirWritable(dir string) error {\n    if err := os.MkdirAll(dir, 0750); err != nil { return err }\n    probe := filepath.Join(dir, \".probe\")\n    if err := os.WriteFile(probe, []byte(\"ok\"), 0600); err != nil { return err }\n    return os.Remove(probe)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-create and chown data directories before start","Mount writable volumes in containers","Ensure dir path does not collide with an existing file"],"tags":["filesystem","mkdir","permissions"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}