mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-26 06:05:54 +03:00
[GH-ISSUE #201] Object retrieval fails with query path constructed by storage.NewReader() #2183
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#2183
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lukevalenta on GitHub (Mar 23, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/201
storage.NewReader() fails to read newly-created object. The reason is that the GET query path is constructed as "/bucket/object" in storage.NewRangeReader, and fake-gcs-server appears to only support paths like "/storage/v1/b/bucket/o/object".
Steps to recreate the issue are below:
From the server logs we can see that the cURL object retrieval works with the path "/storage/v1/b/test-bucket/o/test-file", but the Go client's object retrieval with path "/test-bucket/test-file" fails.
The Go client works with a real GCS server. Changing the URL path to "/storage/v1/b/%s/o/%s" in the storage.NewRangeReader function also works.
@Terminator637 commented on GitHub (Apr 10, 2020):
I got the same problem.
@someone1 commented on GitHub (Apr 16, 2020):
I fixed this by running with
public-host=localhostas part of the command line options, and my code connects tohttps://localhost:4443@Terminator637 commented on GitHub (Apr 17, 2020):
Thank you! I found another closed issue with this problem https://github.com/fsouza/fake-gcs-server/issues/196
@lukevalenta commented on GitHub (Apr 29, 2020):
Excellent! I'll close this ticket then. Changing to the below docker-compose file fixes this example:
@anz-rfc commented on GitHub (May 25, 2020):
For anyone trying else to get this to work locally, be aware that you need to configure
fake-gcs-server's-public-hostto exactly match the the host used to configurestorage.NewClientendpoint that is used to connect to the fake storage.i.e. the following will NOT integrate:
as the server's mux config will not match "localhost" to the "0.0.0.0" PublicHost value endpoint here:
github.com/fsouza/fake-gcs-server@d2b72b590a/fakestorage/server.go (L187)instead, you must use
localhostwhen configuring both client and server, or use0.0.0.0when configuring both client and server.@anz-rfc commented on GitHub (May 25, 2020):
Arguably, it might make configuration less error prone if
-public-hostwas made a mandatory argument with no default, and the servermuxrouting was rewritten to usepublic-hostas host for all endpoints, not just some of them, so if you didnt explicitly configurefake-gcs-serverproperly from the start then no api calls worked, instead of some api calls working but other ones not working. But perhaps that departs from how GCS API actually works (?)@byF commented on GitHub (Jun 3, 2020):
This definitely needs to be in the main readme, I spent so much time trying to figure this out.
@rogierlommers commented on GitHub (Oct 13, 2020):
How does this work with the
docker run-example? Can we somehow add this-public-hostflag to the docker run command?@lukevalenta commented on GitHub (Oct 13, 2020):
You should be able to do this by overriding the entrypoint (https://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime). Something like this (although I haven't tested it):
@rogierlommers commented on GitHub (Oct 14, 2020):
Thanks for your suggestion, unfortunately I get an error:
Which is strange, because indeed the file exists within the container. For some reason it looks like the additional cli flags are messing this up. Any other suggestions?
@rogierlommers commented on GitHub (Oct 14, 2020):
Never mind, turns out that entrypoint and (optional) additional command line flags need to be separated. Not very user-friendly of the docker-cli in my opinion. But hey... it works 👍 .
For future reference:
If you run the container with this:
Then you can initiate the Go client with this:
And you can download a (mocked) file with this:
Thanks, @ltv511 for pointing me in the right direction.