Skip to content

Conversation

@Lyndon-Li
Copy link
Contributor

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:

  • It is helpful for troubleshooting. Any data change to the repository is critical, the observability info helps to understand what happened during the maintenance and why that happened
  • It is helpful for users to understand/predict the repo's behavior. The repo data may be stored in a public cloud for which costs are sensitive to scale/duration of data stored. On the other hand, repository has its own policy to manage the data, so the data is not deleted until it is safe enough according to the policy. The observability info helps users to understand how much data is in-use, how much data is out of use and when it is deleted

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.

// 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
Copy link
Contributor Author

@Lyndon-Li Lyndon-Li Nov 5, 2025

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.

Copy link
Collaborator

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.

@Lyndon-Li Lyndon-Li marked this pull request as ready for review November 5, 2025 11:06
Copy link

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

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 ExtendBlobRetentionStats struct to track blob retention extension metrics (blobs to extend, blobs extended, retention period)
  • Updates ExtendBlobRetentionTime function 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)
Copy link

Copilot AI Nov 5, 2025

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.

Suggested change
require.Equal(t, uint32(4), stats.BlobsExtended)
require.Equal(t, uint32(4), stats.BlobsToExtend)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

❌ Patch coverage is 73.07692% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.02%. Comparing base (cb455c6) to head (b952213).
⚠️ Report is 733 commits behind head on master.

Files with missing lines Patch % Lines
repo/maintenance/blob_retain.go 69.23% 4 Missing ⚠️
...po/maintenancestats/stats_extend_blob_retention.go 80.00% 2 Missing ⚠️
repo/maintenance/maintenance_run.go 0.00% 1 Missing ⚠️
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.
📢 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.

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)
Copy link
Collaborator

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.

Comment on lines +13 to +14
BlobsToExtend uint32 `json:"blobsToExtend"`
BlobsExtended uint32 `json:"blobsExtended"`
Copy link
Collaborator

@julio-lopez julio-lopez Nov 5, 2025

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 ?

Suggested change
BlobsToExtend uint32 `json:"blobsToExtend"`
BlobsExtended uint32 `json:"blobsExtended"`
ToExtendBlobCount uint32 `json:"toExtendBlobCount"`
ExtendedBlobCount uint32 `json:"extendedBlobCount"`

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

@julio-lopez julio-lopez left a comment

Choose a reason for hiding this comment

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

Comment on lines +13 to +14
BlobsToExtend uint32 `json:"blobsToExtend"`
BlobsExtended uint32 `json:"blobsExtended"`
Copy link
Collaborator

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
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@julio-lopez julio-lopez merged commit af38dfc into kopia:master Nov 6, 2025
22 of 23 checks passed
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