Repository navigation
Add report-only S3 carve orphan scan - #1276
Merged
Merged
Conversation
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.
Add report-only S3 carve orphan scan
Summary
Adds a read-only scan for S3 carve objects that no longer have matching metadata. It is available through:
GET /api/v1/carves/{env}/orphansosctrl-cli carve orphans --env <env> [--grace <seconds>]The scan lists objects under the environment prefix, compares them with
carved_blocksandcarved_filesreferences, and reports orphaned keys. It never deletes objects.Closes #1260.
Motivation
Retention deletes stored carve objects before deleting their metadata, so a normal sweep does not create orphans. Orphans can still exist after:
Without a reference-based scan, those objects consume bucket space indefinitely.
Changes
Carve orphan detection
pkg/carves/orphans.go.FindOrphans(ctx, environment, olderThan)lists S3 objects under the environment prefix.carved_blocks.datacarved_files.archive_pathCarverS3.ListObjects(ctx, prefix)using paginatedListObjectsV2, with size and last-modified metadata.API
GET /api/v1/carves/{env}/orphans.grace_seconds:3600604800(7 days)409 Conflictwhen the configured carver is not S3.CLI
Added:
osctrl-api.json,csv, andprettyoutput formats.OsctrlAPI.GetCarveOrphansto the REST client.Documentation and OpenAPI
ARCHITECTURE.mdunder Data Retention.README.md.osctrl-api.yaml;make openapi-checkpasses.Safety and limitations
<environment>:).Tests
ErrOrphanScanUnsupported.grace_secondsand decodes the report.Validation
go test ./...— passed.make openapi-check— passed.git diff --check— clean.Follow-ups