Skip to content

Commit 2332f67

Browse files
branczclaudepre-commit-ci-lite[bot]
authored
Add purged state for debuginfo cleanup (#6030)
* Add purged state for debuginfo uploads This commit introduces a new STATE_PURGED state to track debuginfo that has been cleaned up from storage. This allows the system to: 1. Signal to users that debuginfo existed but was purged/cleaned up 2. Allow re-uploading of purged debuginfo 3. Prevent symbolization attempts with purged debuginfo Changes: - Add STATE_PURGED enum value to proto definition - Update generated Go and TypeScript code - Add MarkAsPurged method to ObjectStoreMetadata - Handle purged state in ShouldInitiateUpload (allows re-upload) - Handle purged state in symbolizer (returns ErrDebuginfoPurged) - Add ErrDebuginfoPurged error definition * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b239f39 commit 2332f67

7 files changed

Lines changed: 46 additions & 5 deletions

File tree

gen/proto/go/parca/debuginfo/v1alpha1/debuginfo.pb.go

Lines changed: 8 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/debuginfo/fetcher.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
var (
2727
ErrUnknownDebuginfoSource = errors.New("unknown debuginfo source")
2828
ErrNotUploadedYet = errors.New("debuginfo not uploaded yet")
29+
ErrDebuginfoPurged = errors.New("debuginfo has been purged")
2930
)
3031

3132
type Fetcher struct {

pkg/debuginfo/metadata.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,21 @@ func (m *ObjectStoreMetadata) MarkAsUploaded(ctx context.Context, buildID, uploa
105105
return m.write(ctx, dbginfo)
106106
}
107107

108+
func (m *ObjectStoreMetadata) MarkAsPurged(ctx context.Context, buildID string, typ debuginfopb.DebuginfoType) error {
109+
dbginfo, err := m.Fetch(ctx, buildID, typ)
110+
if err != nil {
111+
return err
112+
}
113+
114+
if dbginfo.Upload == nil {
115+
return ErrUploadMetadataNotFound
116+
}
117+
118+
dbginfo.Upload.State = debuginfopb.DebuginfoUpload_STATE_PURGED
119+
120+
return m.write(ctx, dbginfo)
121+
}
122+
108123
func (m *ObjectStoreMetadata) Fetch(ctx context.Context, buildID string, typ debuginfopb.DebuginfoType) (*debuginfopb.Debuginfo, error) {
109124
path := metadataObjectPath(buildID, typ)
110125
r, err := m.bucket.Get(ctx, path)

pkg/debuginfo/store.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ const (
126126
ReasonDebuginfoInvalid = "Debuginfo already exists but is marked as invalid, therefore a new upload is needed. Hash the debuginfo and initiate the upload."
127127
ReasonDebuginfoEqual = "Debuginfo already exists and is marked as invalid, but the proposed hash is the same as the one already available, therefore the upload is not accepted as it would result in the same invalid debuginfos."
128128
ReasonDebuginfoNotEqual = "Debuginfo already exists but is marked as invalid, therefore a new upload will be accepted."
129+
ReasonDebuginfoPurged = "Debuginfo was previously uploaded but has been purged/cleaned up, therefore a new upload is needed."
129130
ReasonDebuginfodSource = "Debuginfo is available from debuginfod already and not marked as invalid, therefore no new upload is needed."
130131
ReasonDebuginfodInvalid = "Debuginfo is available from debuginfod already but is marked as invalid, therefore a new upload is needed."
131132
)
@@ -237,6 +238,12 @@ func (s *Store) ShouldInitiateUpload(ctx context.Context, req *debuginfopb.Shoul
237238
ShouldInitiateUpload: true,
238239
Reason: ReasonDebuginfoNotEqual,
239240
}, nil
241+
case debuginfopb.DebuginfoUpload_STATE_PURGED:
242+
// Debuginfo was purged, allow re-uploading
243+
return &debuginfopb.ShouldInitiateUploadResponse{
244+
ShouldInitiateUpload: true,
245+
Reason: ReasonDebuginfoPurged,
246+
}, nil
240247
default:
241248
return nil, status.Error(codes.Internal, "metadata inconsistency: unknown upload state")
242249
}

pkg/symbolizer/symbolizer.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ func (s *Symbolizer) getDebuginfo(ctx context.Context, buildID string) (string,
202202

203203
switch dbginfo.Source {
204204
case debuginfopb.Debuginfo_SOURCE_UPLOAD:
205-
if dbginfo.Upload.State != debuginfopb.DebuginfoUpload_STATE_UPLOADED {
205+
switch dbginfo.Upload.State {
206+
case debuginfopb.DebuginfoUpload_STATE_UPLOADED:
207+
// Good to proceed
208+
case debuginfopb.DebuginfoUpload_STATE_PURGED:
209+
return "", nil, nil, debuginfo.ErrDebuginfoPurged
210+
default:
206211
return "", nil, nil, debuginfo.ErrNotUploadedYet
207212
}
208213
case debuginfopb.Debuginfo_SOURCE_DEBUGINFOD:

proto/parca/debuginfo/v1alpha1/debuginfo.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ message DebuginfoUpload {
230230
STATE_UPLOADING = 1;
231231
// The debuginfo has been uploaded successfully.
232232
STATE_UPLOADED = 2;
233+
// The debuginfo has been purged/cleaned up from storage.
234+
STATE_PURGED = 3;
233235
}
234236

235237
// State is the current state of the debuginfo upload.

ui/packages/shared/client/src/parca/debuginfo/v1alpha1/debuginfo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,13 @@ export enum DebuginfoUpload_State {
423423
*
424424
* @generated from protobuf enum value: STATE_UPLOADED = 2;
425425
*/
426-
UPLOADED = 2
426+
UPLOADED = 2,
427+
/**
428+
* The debuginfo has been purged/cleaned up from storage.
429+
*
430+
* @generated from protobuf enum value: STATE_PURGED = 3;
431+
*/
432+
PURGED = 3
427433
}
428434
/**
429435
* DebuginfoQuality is the quality of the debuginfo.

0 commit comments

Comments
 (0)