{"record":{"id":"92ef69f429608a64","repo":"thanos-io/thanos","slug":"open-dir","errorCode":null,"errorMessage":"open dir","messagePattern":"open dir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/shipper/shipper.go","lineNumber":527,"sourceCode":"\tmeta.Thanos.Source = s.source\n\tmeta.Thanos.SegmentFiles = block.GetSegmentFiles(absUpdir)\n\tif err := meta.WriteToDir(s.logger, absUpdir); err != nil {\n\t\treturn errors.Wrap(err, \"write meta file\")\n\t}\n\tvar uploadOptions []objstore.UploadOption\n\tif s.uploadConcurrency > 0 {\n\t\tuploadOptions = append(uploadOptions, objstore.WithUploadConcurrency(s.uploadConcurrency))\n\t}\n\treturn block.Upload(ctx, s.logger, s.bucket, absUpdir, s.hashFunc, uploadOptions...)\n}\n\n// blockMetasFromOldest returns the block meta of each block found in dir\n// sorted by minTime asc.\nfunc (s *Shipper) blockMetasFromOldest() (metas []*metadata.Meta, failedBlocks []string, _ error) {\n\n\tdir, err := s.dir.Open(\".\")\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"open dir\")\n\t}\n\tdefer runutil.CloseWithLogOnErr(s.logger, dir, \"shipper dir\")\n\n\tfis, err := dir.ReadDir(-1)\n\tif err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"read dir\")\n\t}\n\n\tnames := make([]string, 0, len(fis))\n\tfor _, fi := range fis {\n\t\tnames = append(names, fi.Name())\n\t}\n\tfor _, n := range names {\n\t\tif _, ok := block.IsBlockDir(n); !ok {\n\t\t\tcontinue\n\t\t}\n\t\tdir := filepath.Join(s.dir.Name(), n)\n","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/shipper/shipper.go#L509-L545","documentation":"This error wraps a failure from s.dir.Open(\".\") inside blockMetasFromOldest, which opens the shipper's local directory to enumerate block directories. The shipper dir is an afero Fs abstraction over the TSDB dir; if it cannot be opened, no block metas can be listed and Sync/AreAllBlocksUploaded fail.","triggerScenarios":"Calling Shipper.Sync or AreAllBlocksUploaded when the configured shipper directory no longer exists (deleted/renamed), is not accessible due to permissions, or the underlying filesystem is unavailable/unmounted.","commonSituations":"Misconfigured --prometheus.tsdb.path / shipper dir path pointing to a non-existent location; NFS or cloud volume detach; directory removed by aggressive retention cleanup while the sidecar was running.","solutions":["Verify the shipper/TSDB directory path exists and is readable: ls -ld <dir>; fix the configured path if wrong.","Fix permissions so the process can open the directory (chown/chmod).","Check the volume is mounted (df -h, mount output); remount if detached.","Restart the process after restoring the directory so afero's dir handle is re-established."],"exampleFix":"// before: wrong path configured\n--prometheus.tsdb.path=/prometheus/data/typo\n\n// after: point to the actual TSDB dir\n--prometheus.tsdb.path=/prometheus","handlingStrategy":"validation","validationCode":"info, err := os.Stat(shipperDir)\nif os.IsNotExist(err) {\n    return fmt.Errorf(\"shipper dir %s does not exist\", shipperDir)\n}\nif err != nil {\n    return err\n}\nif !info.IsDir() {\n    return fmt.Errorf(\"%s is not a directory\", shipperDir)\n}","typeGuard":"func dirExistsAndReadable(path string) bool {\n    info, err := os.Stat(path)\n    return err == nil && info.IsDir()\n}","tryCatchPattern":"dir, err := s.dir.Open(\".\")\nif err != nil {\n    if os.IsNotExist(err) {\n        return nil, nil, errors.Wrapf(err, \"open dir: shipper dir missing, check configured path\")\n    }\n    return nil, nil, errors.Wrap(err, \"open dir\")\n}","preventionTips":["Validate the --prometheus.tsdb.path flag at startup before syncing.","Use a StatefulSet/localhost mount so the TSDB path is stable across restarts.","Check volume mount health in orchestration (no detached PVs).","Fix directory ownership/permissions before starting the sidecar."],"tags":["go","filesystem","directory","shipper","io"],"backgroundTag":"file-open-failed","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"}