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

[S3 gateway] Return HTTP 409 (Conflict) when creating existing repo #2451

Conversation

arielshaqed
Copy link
Contributor

When copying to a new key, Rclone likes to try to create all the S3 path
down (it seems to think it's on a POSIXy filesystem so it mkdir -ps). A
repository cannot be created by the gateway -- there is not enough info on
the request -- but if we return a 409 (conflict) then Rclone continues and
succeeds.

There is no S3 gateway test, so tested manually using Rclone.

Fixes #2447.

When copying to a new key, Rclone likes to try to create _all_ the S3 path
down (it seems to think it's on a POSIXy filesystem so it `mkdir -p`s).  A
repository cannot be created by the gateway -- there is not enough info on
the request -- but if we return a 409 (conflict) then Rclone continues and
succeeds.

There is no S3 gateway test, so tested manually using Rclone.

Fixes #2447.
Copy link
Contributor

@guy-har guy-har left a comment

Choose a reason for hiding this comment

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

Looks good
Thanks!

func (controller *PutBucket) RequiredPermissions(_ *http.Request, repoID string) ([]permissions.Permission, error) {
return []permissions.Permission{
{
Action: permissions.ReadRepositoryAction,
Copy link
Contributor

Choose a reason for hiding this comment

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

use CreateRepositoryAction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes! You're right, S3 only accepts a single permission. So if I don't have CreateBucket permission on S3 and I try to create-bucket, I get 403 (AccessDenied) rather than 409 (BucketAlreadyOwnedByYou).

Switching to match. 🤷

@arielshaqed
Copy link
Contributor Author

Thanks!

@arielshaqed arielshaqed merged commit a0713b3 into master Sep 5, 2021
@arielshaqed arielshaqed deleted the feature/2447-s3-gw-return-conflict-when-creating-existing-repo branch September 5, 2021 15:51
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.

RClone requires S3 setting no-check-bucket
2 participants