-
Notifications
You must be signed in to change notification settings - Fork 594
feat(general): add stats to maintenance run - ExtendBlobRetentionStats #4956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(general): add stats to maintenance run - ExtendBlobRetentionStats #4956
Conversation
| // ExtendBlobRetentionTime extends the retention time of all relevant blobs managed by storage engine with Object Locking enabled. | ||
| func ExtendBlobRetentionTime(ctx context.Context, rep repo.DirectRepositoryWriter, opt ExtendBlobRetentionTimeOptions) (int, error) { | ||
| // | ||
| //nolint:funlen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length of this function(108) has exceeded the limit (100 lines).
I didn't find a way to split it without breaking its struct and logic.
So nolint:funlen is added for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be addressed in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds observability for the ExtendBlobRetention maintenance task by introducing structured statistics tracking. The enhancement allows users to monitor blob retention extension operations, which is valuable for troubleshooting maintenance activities and understanding repository behavior in cloud storage environments where costs are sensitive to data retention periods.
Key Changes:
- Introduces
ExtendBlobRetentionStatsstruct to track blob retention extension metrics (blobs to extend, blobs extended, retention period) - Updates
ExtendBlobRetentionTimefunction to return statistics instead of just a count - Adds comprehensive test coverage for the new statistics type
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| repo/maintenancestats/stats_extend_blob_retention.go | Defines the new ExtendBlobRetentionStats struct with JSON serialization and human-readable summary methods |
| repo/maintenancestats/builder.go | Registers the new stats type in the builder's switch statement for deserialization |
| repo/maintenancestats/builder_test.go | Adds test cases for serialization/deserialization of ExtendBlobRetentionStats |
| repo/maintenance/blob_retain.go | Refactors ExtendBlobRetentionTime to create and return ExtendBlobRetentionStats instead of integer count |
| repo/maintenance/maintenance_run.go | Updates task runner to properly handle the new stats return value |
| repo/maintenance/blob_retain_test.go | Updates existing tests to validate the returned statistics |
| stats, err := maintenance.ExtendBlobRetentionTime(ctx, env.RepositoryWriter, maintenance.ExtendBlobRetentionTimeOptions{}) | ||
| require.NoError(t, err) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) |
Copilot
AI
Nov 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 77 duplicates the assertion from line 76. This appears to be a copy-paste error. The second assertion should verify stats.BlobsToExtend instead of stats.BlobsExtended again.
| require.Equal(t, uint32(4), stats.BlobsExtended) | |
| require.Equal(t, uint32(4), stats.BlobsToExtend) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging as is, fixing in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4956 +/- ##
==========================================
+ Coverage 75.86% 78.02% +2.15%
==========================================
Files 470 545 +75
Lines 37301 31368 -5933
==========================================
- Hits 28299 24475 -3824
+ Misses 7071 4848 -2223
- Partials 1931 2045 +114 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| stats, err := maintenance.ExtendBlobRetentionTime(ctx, env.RepositoryWriter, maintenance.ExtendBlobRetentionTimeOptions{}) | ||
| require.NoError(t, err) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging as is, fixing in a separate PR.
| BlobsToExtend uint32 `json:"blobsToExtend"` | ||
| BlobsExtended uint32 `json:"blobsExtended"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are "blob counts", right ?
| BlobsToExtend uint32 `json:"blobsToExtend"` | |
| BlobsExtended uint32 `json:"blobsExtended"` | |
| ToExtendBlobCount uint32 `json:"toExtendBlobCount"` | |
| ExtendedBlobCount uint32 `json:"extendedBlobCount"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
julio-lopez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| BlobsToExtend uint32 `json:"blobsToExtend"` | ||
| BlobsExtended uint32 `json:"blobsExtended"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // ExtendBlobRetentionTime extends the retention time of all relevant blobs managed by storage engine with Object Locking enabled. | ||
| func ExtendBlobRetentionTime(ctx context.Context, rep repo.DirectRepositoryWriter, opt ExtendBlobRetentionTimeOptions) (int, error) { | ||
| // | ||
| //nolint:funlen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be addressed in a separate PR.
| stats, err := maintenance.ExtendBlobRetentionTime(ctx, env.RepositoryWriter, maintenance.ExtendBlobRetentionTimeOptions{}) | ||
| require.NoError(t, err) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) | ||
| require.Equal(t, uint32(4), stats.BlobsExtended) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintenance is critical for healthy of the repository.
On the other hand, Maintenance is complex, because it runs multiple sub tasks each may generate different results according to the maintenance policy. The results may include deleting/combining/adding data/metadata to the repository.
It is worthy to add more observability for these tasks for below reasons:
There will be a serial of PRs to add observability info for each sub task.
The current PR add the stats info for ExtendBlobRetention sub task.