Skip to content

Fix getDiskUsage and add getCollectionStats#2605

Open
delthas wants to merge 1 commit intodevelopment/8.3from
improvement/ARSN-566/disk-space-check-lifecycle
Open

Fix getDiskUsage and add getCollectionStats#2605
delthas wants to merge 1 commit intodevelopment/8.3from
improvement/ARSN-566/disk-space-check-lifecycle

Conversation

@delthas
Copy link
Copy Markdown

@delthas delthas commented Apr 1, 2026

Summary

  • Fix getDiskUsage: Was reading the nonexistent fsFreeSize field from MongoDB's dbStats command, always returning 0 for available/free space. Now correctly computes free space as fsTotalSize - fsUsedSize.
  • Add getCollectionStats: New method on MongoClientInterface that exposes per-collection stats via the collStats command. Returns the raw stats object including indexSizes (per-index size breakdown) and totalIndexSize.

Context

The lifecycle conductor (BB-753) needs to check available disk space before creating v2 indexes on MongoDB. When the MongoDB PV is nearly full, attempting index creation can fail (ENOSPC) or further pressure the disk. The conductor uses getDiskUsage for filesystem free space and getCollectionStats to get the _id_ index size as an estimate for the cost of creating lifecycle indexes.

Design decisions

  • getDiskUsage keeps its existing return shape ({ available, free, total }) to avoid breaking the interface contract, just fixes the computation.
  • getCollectionStats passes stats through directly from MongoDB rather than reshaping — the caller extracts what it needs.
  • Uses db.command({ collStats }) instead of the deprecated collection.stats() which was removed from the MongoDB Node.js driver type definitions.
  • Both calls are metadata-only (~3ms and ~8ms respectively on a 1M-document collection), no collection scans or locks.

getDiskUsage was reading the nonexistent fsFreeSize field from
MongoDB's dbStats, always returning 0. Fix it to compute free
space as fsTotalSize - fsUsedSize.

Add getCollectionStats method that exposes per-collection stats
via the collStats command. This is needed by the lifecycle
conductor to check disk space before creating indexes (BB-753).

Issue: ARSN-566
@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Apr 1, 2026

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@claude
Copy link
Copy Markdown

claude bot commented Apr 1, 2026

LGTM

Review by Claude Code

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.38%. Comparing base (eefeb8b) to head (a971a53).

Additional details and impacted files
@@                 Coverage Diff                 @@
##           development/8.3    #2605      +/-   ##
===================================================
+ Coverage            73.37%   73.38%   +0.01%     
===================================================
  Files                  222      222              
  Lines                18160    18168       +8     
  Branches              3761     3761              
===================================================
+ Hits                 13324    13332       +8     
  Misses                4831     4831              
  Partials                 5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@scality scality deleted a comment from bert-e Apr 2, 2026
@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Apr 2, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

@delthas delthas changed the title ARSN-566: Fix getDiskUsage and add getCollectionStats Fix getDiskUsage and add getCollectionStats Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants