Skip to content
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

upload: restore behavior when ifGenerationMatch=0 for the fs backend #745

Merged
merged 1 commit into from
Apr 8, 2022

Conversation

fsouza
Copy link
Owner

@fsouza fsouza commented Apr 8, 2022

This change is a follow-up to #735: previously, ifGenerationMatch=0 was
special-cased and the server used GetObject, which works on filesystem
and memory backends. That pull request changed the code to use
GetObjectWithGeneration, which is not supported by the filesystem
backend.

We couldn't catch this in tests because the test suite only runs with
the memory backend, so as part of this change I'm also including the
ability to use the filesystem storage in the test suite. That can get
slow though.

This is a hack and should be revisited once we implement #744.

This change is a follow-up to #735: previously, ifGenerationMatch=0 was
special-cased and the server used GetObject, which works on filesystem
and memory backends. That pull request changed the code to use
GetObjectWithGeneration, which is not supported by the filesystem
backend.

We couldn't catch this in tests because the test suite only runs with
the memory backend, so as part of this change I'm also including the
ability to use the filesystem storage in the test suite. That can get
slow though.

This is a hack and should be revisited once we implement #744.
@fsouza
Copy link
Owner Author

fsouza commented Apr 8, 2022

@orsinium can you confirm that this works for you? If so, I can go ahead and merge this PR, then tag a new release.

Comment on lines -163 to +171
_, err = s.backend.GetObjectWithGeneration(bucketName, objectName, gen)
if gen == 0 {
_, err := s.backend.GetObject(bucketName, objectName)
if err == nil {
return &jsonResponse{
status: http.StatusPreconditionFailed,
errorMessage: "Precondition failed",
}
}
} else if err != nil {
} else if _, err := s.backend.GetObjectWithGeneration(bucketName, objectName, gen); err != nil {
Copy link
Owner Author

Choose a reason for hiding this comment

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

The diff looks much larger because I had to build the capability to use the filesystem backend in tests, but this is the meat of it.

@fsouza fsouza merged commit a171eff into main Apr 8, 2022
@fsouza fsouza deleted the ifGenerationMatch-backwards-compatibility branch April 8, 2022 14:33
@orsinium
Copy link

orsinium commented Apr 9, 2022

I'm late to the party :) I see it's already merged. Do you still need my input? You can also try to run the script I attached to the issue, it reproduces the bug.

@fsouza
Copy link
Owner Author

fsouza commented Apr 9, 2022

I'm late to the party :) I see it's already merged. Do you still need my input? You can also try to run the script I attached to the issue, it reproduces the bug.

Yes, looks like we're good!

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