Fix getDiskUsage and add getCollectionStats#2605
Open
delthas wants to merge 1 commit intodevelopment/8.3from
Open
Fix getDiskUsage and add getCollectionStats#2605delthas wants to merge 1 commit intodevelopment/8.3from
delthas wants to merge 1 commit intodevelopment/8.3from
Conversation
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
Contributor
Hello delthas,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
|
LGTM |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Contributor
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getDiskUsage: Was reading the nonexistentfsFreeSizefield from MongoDB'sdbStatscommand, always returning 0 for available/free space. Now correctly computes free space asfsTotalSize - fsUsedSize.getCollectionStats: New method onMongoClientInterfacethat exposes per-collection stats via thecollStatscommand. Returns the raw stats object includingindexSizes(per-index size breakdown) andtotalIndexSize.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
getDiskUsagefor filesystem free space andgetCollectionStatsto get the_id_index size as an estimate for the cost of creating lifecycle indexes.Design decisions
getDiskUsagekeeps its existing return shape ({ available, free, total }) to avoid breaking the interface contract, just fixes the computation.getCollectionStatspasses stats through directly from MongoDB rather than reshaping — the caller extracts what it needs.db.command({ collStats })instead of the deprecatedcollection.stats()which was removed from the MongoDB Node.js driver type definitions.