-
Notifications
You must be signed in to change notification settings - Fork 322
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: delete staging and load files post successful sync #5428
Conversation
b07c7f6
to
f333dfc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5428 +/- ##
==========================================
- Coverage 74.82% 74.76% -0.07%
==========================================
Files 440 440
Lines 61668 61705 +37
==========================================
- Hits 46145 46134 -11
- Misses 12987 13021 +34
- Partials 2536 2550 +14 ☔ View full report in Codecov by Sentry. |
f333dfc
to
47e7504
Compare
if err = job.cleanupObjectStorageFiles(); err != nil { | ||
break | ||
} |
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.
@shekhar-rudder Say if this fails. Would the job be retried? If yes, in next retry would it continue from just cleanupObjectStorageFiles
?
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.
@shekhar-rudder @achettyiitr Also from PRD doc, did we close on failing the job or considering metric and internal alert 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.
@RanjeetMishra If the cleanup fails, the job will be marked as failed. On the next retry, I would assume it will proceed as it would for any other error.
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.
Since now it is config based deletion, I think its fine to mark the job as failed. If customer doesn't want the syncs to error out, they can always turn it off.
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.
Seems fine if we are aligning with marking sync jobs as failed. Regarding destination config for old and new destinations lets finalize tomorrow. This PR is good to go in that case.
warehouse/router/upload.go
Outdated
filesToDelete := make([]string, len(job.stagingFiles)+len(loadingFiles)) | ||
for i, file := range job.stagingFiles { | ||
filesToDelete[i] = fm.GetDownloadKeyFromFileLocation(file.Location) | ||
} | ||
for i, file := range loadingFiles { | ||
filesToDelete[i+len(job.stagingFiles)] = fm.GetDownloadKeyFromFileLocation(file.Location) | ||
} |
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.
minor: Can see if you like lo
map here.
fileKeysToDel := lo.Map(job.stagingFiles, func(file FileType, _ int) string {
return fm.GetDownloadKeyFromFileLocation(file.Location)
})
loadingFilesKeys := lo.Map(loadingFiles, func(file FileType, _ int) string {
return fm.GetDownloadKeyFromFileLocation(file.Location)
})
fileKeysToDel = append(fileKeysToDel, loadingFilesKeys...)
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.
Replaced with lo
Description
This PR introduces support for cleaning up staging and load files from object storage based on the user preference (cleanupObjectStorageFiles). If file deletion fails, the job will be marked as failed. The cleanup process occurs just before marking the job as complete.
Implementation Details
The
UploadJob
struct already includesstagingFiles
. Using their ids, the corresponding load files are retrieved. Keys are then computed from the locations of both file types, and the files are deleted.Security