Repository navigation
pkg/chartmuseum/server/multitenant: remove stored files from the right path on failed uploads - #1162
Merged
Conversation
…t path on failed uploads When a multipart upload with a chart and a provenance file fails while storing the second file, the handler tries to remove the first one. It passed only the bare file name to DeleteObject, but the files are stored under the repo prefix, so with a repo in the URL the delete hit a path that does not exist. The chart stayed in storage without being indexed, and uploading it again was answered with a conflict. Delete the object under its repo path, and log the chart parse error instead of the always nil upload error. Signed-off-by: vigneshwar <applemacbook6sep2004@gmail.com>
Contributor
|
LGTM |
Contributor
Author
|
Thanks a lot for taking this in. It was a small path mix up, but on a multitenant setup it would quietly leave orphaned chart files behind after a failed upload, so I am glad it is fixed. |
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.
What this PR does / why we need it:
When a multipart upload carries a chart and a provenance file and storing the second file fails, the handler removes the file it already saved. It called
DeleteObjectwith the bare file name, but the files are stored under the repo prefix, so with a repo in the URL the delete pointed at a path that does not exist.The first file then stayed in storage without ever reaching the index, and uploading the chart again was answered with a 409 because the file already existed. This deletes the object under
repo/filename. It also logs the chart parse error there instead oferr, which is always nil at that point.I added a test with a storage backend that fails the second
PutObject. It uploads to a depth 1 repo, checks that nothing is left behind and that a retry returns 201. On main the leftover file is there and the retry gets 409.