{"record":{"id":"ba4bdbc5323af243","repo":"prometheus/node_exporter","slug":"failed-to-retrieve-bcachefs-stats-w","errorCode":null,"errorMessage":"failed to retrieve bcachefs stats: %w","messagePattern":"failed to retrieve bcachefs stats: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/bcachefs_linux.go","lineNumber":141,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open sysfs: %w\", err)\n\t}\n\n\treturn &bcachefsCollector{\n\t\tfs:     fs,\n\t\tlogger: logger,\n\t}, nil\n}\n\n// Update retrieves and exports bcachefs statistics.\nfunc (c *bcachefsCollector) Update(ch chan<- prometheus.Metric) error {\n\tstats, err := c.fs.Stats()\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\tc.logger.Debug(\"bcachefs sysfs path does not exist\", \"path\", sysFilePath(\"fs/bcachefs\"))\n\t\t\treturn ErrNoData\n\t\t}\n\t\treturn fmt.Errorf(\"failed to retrieve bcachefs stats: %w\", err)\n\t}\n\n\tif len(stats) == 0 {\n\t\treturn ErrNoData\n\t}\n\n\tfor _, s := range stats {\n\t\tuuid := s.UUID\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tbcachefsInfoDesc,\n\t\t\tprometheus.GaugeValue,\n\t\t\t1,\n\t\t\tuuid,\n\t\t)\n\n\t\tch <- prometheus.MustNewConstMetric(\n\t\t\tbcachefsBtreeCacheSizeBytes,","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/bcachefs_linux.go#L123-L159","documentation":"bcachefsCollector.Update wraps errors from c.fs.Stats() in \"failed to retrieve bcachefs stats\" unless the error is a NotExist (which degrades to ErrNoData). It means the bcachefs sysfs tree was reachable but reading the statistics failed, or the path vanished between construction and scrape. No bcachefs metrics are emitted for the failed scrape.","triggerScenarios":"Mid-scrape unmount/removal of a bcachefs filesystem causing sysfs entries to disappear with an error other than ENOENT, permission changes on /sys/fs/bcachefs files, or I/O failures reading sysfs attributes during the walk.","commonSituations":"Unmounting a bcachefs volume while node_exporter scrapes; containers with restricted sysfs visibility; kernels where bcachefs attribute layout differs from what the procfs package expects.","solutions":["Verify the bcachefs filesystem is still mounted and /sys/fs/bcachefs is populated (ls /sys/fs/bcachefs)","Check dmesg for bcachefs errors and remount the filesystem if it was unmounted or went offline","Confirm the exporter user can read all files under /sys/fs/bcachefs","Accept ErrNoData behavior: if the path simply does not exist, the collector logs a debug and reports no data rather than erroring"],"exampleFix":"// before\n stats, err := c.fs.Stats()\n log.Fatal(err)\n// after\n if err != nil {\n\tvar pathErr *os.PathError\n\tif errors.As(err, &pathErr) && os.IsNotExist(pathErr) {\n\t\treturn ErrNoData\n\t}\n\treturn err\n }","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(\"/sys/fs/bcachefs\"); os.IsNotExist(err) { /* expect ErrNoData, skip */ }","typeGuard":null,"tryCatchPattern":"err := collector.Update(ch)\nif err != nil {\n\tif errors.Is(err, collector.ErrNoData) {\n\t\treturn nil // no bcachefs fs present; benign\n\t}\n\treturn err\n}","preventionTips":["Keep bcachefs filesystems mounted during scrape intervals","Audit permissions on /sys/fs/bcachefs after security policy changes","Track kernel upgrades for bcachefs attribute changes","Treat ErrNoData as benign rather than alerting"],"tags":["linux","sysfs","scrape","bcachefs"],"backgroundTag":"file-read-failed","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}