Skip to content

Add capacity forecast client method#571

Open
cniackz wants to merge 12 commits into
minio:mainfrom
cniackz:feat/capacity-forecast
Open

Add capacity forecast client method#571
cniackz wants to merge 12 commits into
minio:mainfrom
cniackz:feat/capacity-forecast

Conversation

@cniackz
Copy link
Copy Markdown
Contributor

@cniackz cniackz commented Apr 13, 2026

Adds the CapacityForecast struct and the AdminClient.CapacityForecast method that calls GET /admin/v4/capacity-forecast and returns the projection. Days-until threshold fields are pointer floats where nil means no prediction is possible and a negative value means the threshold was already crossed in the past, so magnitude is meaningful. Follows the existing ServerInfo client pattern.

Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
@cniackz cniackz force-pushed the feat/capacity-forecast branch from 1a5d6e9 to 805b4f5 Compare April 13, 2026 20:42
@cniackz cniackz requested a review from klauspost April 13, 2026 22:21
@cniackz cniackz marked this pull request as ready for review April 13, 2026 22:22
@cniackz cniackz force-pushed the feat/capacity-forecast branch 3 times, most recently from a47844e to fc0c35f Compare April 27, 2026 20:37
@cniackz cniackz force-pushed the feat/capacity-forecast branch from fc0c35f to 134a0b6 Compare May 8, 2026 14:16
Copy link
Copy Markdown
Contributor

@klauspost klauspost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if we can qualify the numbers a bit more.

Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
Comment thread capacity-forecast.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Admin API client surface for retrieving storage capacity projection data from MinIO, exposing both current usage and forecasted “days until” threshold crossings.

Changes:

  • Introduces a new CapacityForecast struct to model the /capacity-forecast response (including pointer “days until” fields).
  • Adds AdminClient.CapacityForecast(ctx) to call GET /minio/admin/<v3|v4>/capacity-forecast and decode the JSON response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread capacity-forecast.go
Comment thread capacity-forecast.go
CurrentUsedPercent float64 `json:"currentUsedPercent"`

// Days until each usage threshold is reached. The projection comes from
// a Kalman filter that integrates up to 365 daily samples with greater
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't it 90 days/samples? That should be more than plenty.

Kalman has a pretty high recency bias - I wouldn't expect it to produce any different result from 365.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klauspost the idea is to predict also for companies which flow is longer than 90 days. Need to talk to Kannappan if we need to revert this back to 90.

cniackz added 7 commits May 17, 2026 22:08
Add struct and client method for the new GET /admin/v4/capacity-forecast
endpoint. Returns storage capacity predictions based on historical
daily snapshots.
Add MinDaysUntilFull, RSquared, Variance, RecentGrowthRatePerDay,
and RecentDaysUntilFull to CapacityForecast struct for Phase 2
of the prediction algorithm.
Expose concrete min/max daily usedFraction deltas so consumers can
show the actual extremes alongside the statistical summary.
A -1 sentinel collides with legitimate negative values — e.g. days
until 80%% full can legitimately be -5 when usage already crossed
the threshold 5 days ago. Use *float64 with nil for "unknown"
so the type system represents unset state cleanly.

Addresses review feedback from klauspost.
Update struct and field comments to reflect the switch from OLS
linear regression to a Kalman filter. No code or type changes.
The Kalman filter is the forecaster; an OLS R-squared offered no
information about the filter's own predictions and only measured the
linearity of the raw data. Drop the field to keep the API focused on
what the filter actually computes.
Per review feedback, embed the unit in the names so readers do not
have to look at the implementation to discover what they hold:

- GrowthRatePerDay  -> GrowthBytesPerDay
- DataPointCount    -> DailySnapshotCount

The doc comments now also clarify that GrowthBytesPerDay is independent
of DailySnapshotCount.
cniackz added 2 commits May 17, 2026 22:08
Per review feedback, document the nature of the trend used for the
DaysUntil80/90/100Pct fields: the Kalman filter integrates up to 365
daily samples with recency-weighted emphasis, so a fresh shift in
usage dominates over older history.
The previous fields expressed the change as a fraction in [-1, +1],
which the reviewer found unclear. Bytes match the other size fields
(CurrentUsedBytes, CurrentTotalBytes, GrowthBytesPerDay) and tell
the user directly how much data was added or freed that day.
@cniackz cniackz force-pushed the feat/capacity-forecast branch from e455168 to b957d44 Compare May 18, 2026 02:09
@cniackz cniackz requested a review from klauspost May 19, 2026 16:36
cniackz added 2 commits May 19, 2026 12:48
Cover the request path/method, JSON decoding of *float64 days-until
fields (nil, positive, negative), and the non-200 error path. Addresses
Copilot's review feedback on PR minio#571.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants