{"record":{"id":"9dec502e859ec2d4","repo":"thanos-io/thanos","slug":"open-data-dir","errorCode":null,"errorMessage":"open data dir","messagePattern":"open data dir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/thanos/rule.go","lineNumber":901,"sourceCode":"\t}\n\n\tconfContentYaml, err := conf.objStoreConfig.Content()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(confContentYaml) > 0 {\n\t\t// The background shipper continuously scans the data directory and uploads\n\t\t// new blocks to Google Cloud Storage or an S3-compatible storage service.\n\t\tbkt, err := client.NewBucket(logger, confContentYaml, component.Rule.String(), nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tbkt = objstoretracing.WrapWithTraces(objstore.WrapWithMetrics(bkt, extprom.WrapRegistererWithPrefix(\"thanos_\", reg), bkt.Name()))\n\n\t\tdataDir, err := os.OpenRoot(conf.dataDir)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"open data dir\")\n\t\t}\n\n\t\ts := shipper.New(\n\t\t\tbkt,\n\t\t\tdataDir,\n\t\t\tshipper.WithLogger(logger),\n\t\t\tshipper.WithRegisterer(reg),\n\t\t\tshipper.WithSource(metadata.RulerSource),\n\t\t\tshipper.WithHashFunc(metadata.HashFunc(conf.shipper.hashFunc)),\n\t\t\tshipper.WithMetaFileName(conf.shipper.metaFileName),\n\t\t\tshipper.WithLabels(func() labels.Labels { return conf.lset }),\n\t\t\tshipper.WithAllowOutOfOrderUploads(conf.shipper.allowOutOfOrderUpload),\n\t\t\tshipper.WithSkipCorruptedBlocks(conf.shipper.skipCorruptedBlocks),\n\t\t\tshipper.WithUploadConcurrency(conf.shipper.uploadConcurrency),\n\t\t)\n\n\t\tctx, cancel := context.WithCancel(context.Background())\n","sourceCodeStart":883,"sourceCodeEnd":919,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/cmd/thanos/rule.go#L883-L919","documentation":"When sidecar upload is enabled, runRule opens the rule evaluator's data directory with os.OpenRoot(conf.dataDir) to hand it to the shipper. If the directory cannot be opened (missing, not a directory, permission denied), the error is wrapped as \"open data dir\" and startup aborts.","triggerScenarios":"Running thanos rule with --objstore-bucket (shipper enabled) where --data-dir does not exist and cannot be created/opened, points to a file, or the process lacks read permission on it.","commonSituations":"Forgetting to mount the persistent volume that holds --data-dir in Kubernetes; dataDir typo like /var/thanos/ruel; volume mounted read-only while the shipper needs write access.","solutions":["Ensure --data-dir exists and is a writable directory (mkdir -p and chown to the process user).","Mount a persistent volume at the dataDir path in your container spec.","Fix the --data-dir flag value if it points to a file or a typo'd path.","Remove the read-only flag from the volume mount, or disable shipping if upload is not intended."],"exampleFix":"// before\nthanos rule --data-dir=/mnt/missing/rule --objstore-bucket=thanos\n// after\nmkdir -p /var/thanos/rule && thanos rule --data-dir=/var/thanos/rule --objstore-bucket=thanos","handlingStrategy":"validation","validationCode":"test -d \"$DATA_DIR\" || mkdir -p \"$DATA_DIR\"; test -w \"$DATA_DIR\" || { echo \"data dir not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mount a writable volume at --data-dir when shipping is enabled","Create the directory in an init container","Double-check flag values for typos"],"tags":["filesystem","shipper","startup","config"],"backgroundTag":"directory-not-found","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"}