haskell-works / cabal-cache

CI assistant
BSD 3-Clause "New" or "Revised" License
44 stars 11 forks source link

Wrong region parsing #230

Closed ccomb closed 1 year ago

ccomb commented 1 year ago

I've spent some time filling an issue in haskell/cabal instead of haskell-works/cabal-cache :-( The detail is here: https://github.com/haskell/cabal/issues/8927 But I'm copying the most relevant part:

Describe the bug

The region seems not parsed correctly

To Reproduce

I'm using the latest prebuilt version 1.0.6.1 I'm trying to make it work with an alternative cloud provider (Scaleway). I have a working bucket and can upload to it, and query it with aws --endpoint-url https://s3.fr-par.scw.cloud s3 ls s3://cabal-store.prelab.fr/

I've configured the environment variable:

AWS_SECRET_ACCESS_KEY=##############
AWS_ACCESS_KEY_ID=##############

Then I sync to archive:

$ cabal-cache sync-to-archive --threads 1 --archive-uri s3://cabal-store.prelab.fr --host-name-override=s3.fr-par.scw.cloud --host-port-override=443 --host-ssl-override=True
Store path: /home/ccomb/.cabal/store
Store path hash: 976034e385
Archive URI: s3://cabal-store.prelab.fr/
Archive version: v2
Threads: 1
AWS Log level: Nothing
Syncing 144 packages
Temp path: "/tmp/cabal-cache-54615039913fe989"
Creating s3://cabal-store.prelab.fr//v2/ghc-9.2.7/OneTuple-0.4.1.1-1eb23aee2212396019bfecfe5d8a5b898c274e15271abb05c32e31d0b4142950.tar.gz
ERROR: No write access to archive uris: ["s3://cabal-store.prelab.fr/v2/976034e385/ghc-9.2.7/OneTuple-0.4.1.1-1eb23aee2212396019bfecfe5d8a5b898c274e15271abb05c32e31d0b4142950.tar.gz","s3://cabal-store.prelab.fr//v2/ghc-9.2.7/OneTuple-0.4.1.1-1eb23aee2212396019bfecfe5d8a5b898c274e15271abb05c32e31d0b4142950.tar.gz"] Status {statusCode = 400, statusMessage = "Bad Request"}
Early exit due to error

Then I've discovered the debug option and tried to cabal-cache debug s3 cp from another bucket with the same credentials. I get:

(...)_serviceCode = ErrorCode "AuthorizationHeaderMalformed", _serviceMessage = Just (ErrorMessage "The authorization header is malformed; the region 'us-west-2' is wrong; expecting 'fr-par'"), _serviceRequestId = Just (RequestId "tx3e8f9cb1342145ec9b2ac-00644d740f")})

So there is a problem with the region: the region 'us-west-2' is wrong; expecting 'fr-par'

However I cannot specify the region with --region. I get the following error:

option --region: Failed reading: Failure parsing Region from fr-par

Is the region parsing expecting something like XX-XXXX-XX ?

System information

ccomb commented 1 year ago

Apparently the problem comes from amazonka? https://hackage.haskell.org/package/amazonka-1.6.1/docs/Network-AWS.html#g:5 Is there a way to support a different region?

newhoggy commented 1 year ago

Unfortunately will need an upgrade to amazonka-2.

newhoggy commented 1 year ago

In the interim you could find a region is in common with your storage service and S3 and use that.

newhoggy commented 1 year ago

Does this resolve the issue for you? https://github.com/haskell-works/cabal-cache/pull/232

ccomb commented 1 year ago

Yeah thanks, it works!!