-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
swift: fix file already closed issue #1489
swift: fix file already closed issue #1489
Conversation
d2401ac
to
d4e453d
Compare
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.
LGTM
if err != nil { | ||
return err | ||
} | ||
readSeeker := strings.NewReader(buf.String()) |
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.
This issue seems to be due to a bug in the vendored gophercloud dependency and looks like it has been fixed upstream: https://github.com/rackspace/gophercloud/blob/master/openstack/objectstorage/v1/objects/requests.go#L219. Do you think you could re-vendor gophercloud and run your tests?
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.
sure I can check it
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.
@sudhi-vm looks like gophercloud was moved from github.com/rackspace to https://github.com/gophercloud and it looks like the version 0.3.0 is the latest one.
I am not an io.Reader expert but I guess the ioutil.ReadAll will close the reader and causes this issue.
https://github.com/gophercloud/gophercloud/blob/master/openstack/objectstorage/v1/objects/requests.go#L198-L199
Signed-off-by: Florin Peter <Florin-Alexandru.Peter@t-systems.com>
d4e453d
to
f576a79
Compare
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.
LGTM.
We were able to reproduce the issue without the patch in our local OpenStack cluster and verified that the patch solves the issue.
@FlorinPeter Thanks for submitting the fix!
@bwplotka Can you please help re-run ci.
retest ci |
Done with Ci. This feels a bit like a bug in the library we are using? And this fix feels a bit more like a workaround. As far as I understand the library accepts Maybe you would like to raise an issue with them? IMO it's fine as a short term fix and we can merge it if it solves the problem for swift users. @bwplotka what do you think? |
@povilasv Good point. We upgraded the vendored library (gophercloud) to recent version locally, but it did not fix the issue. I will follow up with gophercloud on this. As you mention, we could merge this and treat it as a short-term fix. Once the fix is identified and merged in gophercloud, we could consume the change and also upgrade the vendored library to more recent version. |
Has this been reported upstream? (: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Are there any progress about this issue? |
ping @sudhi-vm |
FWIW I still haven't gotten around to this because I cannot get my hands on a working Swift cluster. Seems like the community projects which let you run Swift in a small deployment unit are buggy and/or something doesn't work :'( |
Reported upstream at gophercloud/gophercloud#1856. |
Hi folks, I'm currently looking at the issue @GiedriusS reported at gophercloud/gophercloud#1856. There are some details to my current investigation over there. If anyone has any pointers, it would be very much appreciated! |
I was able to get the Thanos S3 e2e tests working and then dug into the minio library to compare behavior. I think I've determined what's going on - there's always room for error, though. At least for the e2e tests, the calculated partSize is always 0 because the files are small and/or they're less than the default vaules of 128mb: https://github.com/thanos-io/thanos/blob/master/pkg/objstore/s3/s3.go#L321-L325 Minio implements a 128mb size as a threshold on when to do multipart/streaming uploads: https://github.com/minio/minio-go/blob/master/api-put-object.go#L171-L174 When the size of the object is less than the default 128mb or whatever was explicitly passed, the following happens: https://github.com/minio/minio-go/blob/master/api-put-object-streaming.go#L335-L344 ta-da! The object data is being wrapped into something that doesn't implement Minio is providing a lot of logic for how the data should be handled prior to being uploaded to S3. This amount of care is intentionally not in Gophercloud. Gophercloud is meant to be a very low-level API. Its core goal is to model the OpenStack REST API with as little convenience and helper functions/methods as possible. This is because OpenStack is a very flexible set of projects and the APIs can be customized from one environment to the next. Implementing any sort of help/convenience opens the door to a lot of help/convenience to account for everyone's needs. Gophercloud's current Swift support provides all of the capabilities to implement the same kind of logic that Minio is doing internally - it just expects it to be done a layer above Gophercloud. We have a repository at https://github.com/gophercloud/utils that is meant to provide helpers/utilities for things that would otherwise be repeated a lot, including support for uploading and downloading objects, too. I've also committed a patch to assist the different kinds of data streams to prevent the original/underlying pointer from being prematurely closed, too. While I tested this and it works, I don't think this object storage code sees a lot of use, so if you folks choose to adopt it, you might run into some bugs. Please feel free to submit PRs or at least a detailed report so this code can be made better -- you'd end up helping anyone else creating an OpenStack-compatible object storage app. If you don't want to adopt the utils code, the solution that this PR is implementing is the best that can be done - possibly additionally implementing the same Please let me know if anyone has any questions or comments. |
Thanks for your impressive analysis! 💪 I have one small question: is there some small tool which would let us start a small Now about this PR itself... maybe we shouldn't even log at all that a As for the other library, I would love to switch myself but we probably don't have enough human resources for that :( |
No problem at all 🙂
There are a few ways. What you're looking for is something called Swift AIO (all-in-one). There are a bunch of scripts around that will build this. One option is to use the official OpenStack devstack project:
The above will take around 5-6 minutes. When complete, you'll have a local OpenStack environment that only has Keystone (authentication) and Swift running:
IMO, I'm quite thankful that this was being logged. It allowed me to catch an inefficiency, enhance the
I totally understand - I'm in the same situation! |
Changes
Fix file already closed issue by passing a reader that supports seek to the swift implementation.
Verification
Tested locally without fix:
With the fix: