-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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: log human readable error on connection failure #26856
Conversation
Some linter errors. |
1197486
to
10d9f2a
Compare
Instead of introducing -> Move web/api context related testing function into a separate package #26859 See the TODO comment of the MockContext:
|
10d9f2a
to
159c54d
Compare
The commit related to MockVariableValue was removed, it does not belong here. |
I am not sure whether it is right. According to https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketVersioning.html
Then, are you sure that the non-owner but writer users could still run Gitea correctly? |
|
That's quite tricky. Could there be some comments to explain the design and behavior? eg: // The GetBucketVersioning is only used for checking whether the Object Storage parameters are generally good. It doesn't need to succeed.
// The assumption is that if the API returns the HTTP code 400, then the parameters could be incorrect.
// Otherwise even if the request itself fails (403, 404, etc), the code should still continue because the parameters seem "good" enough.
// Keep in mind that GetBucketVersioning requires "owner" to really succeed, so it can't be used to check the existence.
// Not using "BucketExists (HeadBucket)" because it doesn't include detailed failure reasons. |
Should BucketExists (HeadBucket) fail because of an error related to the connection rather than the existence of the bucket, no information is available and the admin is left guessing. https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html > This action is useful to determine if a bucket exists and you have > permission to access it. The action returns a 200 OK if the bucket > exists and you have permission to access it. > > If the bucket does not exist or you do not have permission to access > it, the HEAD request returns a generic 400 Bad Request, 403 > Forbidden or 404 Not Found code. A message body is not included, so > you cannot determine the exception beyond these error codes. GetBucketVersioning is used instead and exclusively dedicated to asserting if using the connection does not return a BadRequest. If it does the NewMinioStorage logs an error and returns. Otherwise it keeps going knowing that BucketExists is not going to fail for reasons unrelated to the existence of the bucket and the permissions to access it. (cherry picked from commit d1df4b3bc62e5e61893a923f1c4b58f084eb03af) Refs: https://codeberg.org/forgejo/forgejo/issues/1338
159c54d
to
13fe28b
Compare
* upstream/main: Add more package registry paths to the labeler (go-gitea#27032) Extract auth middleware from service (go-gitea#27028) S3: log human readable error on connection failure (go-gitea#26856) [skip ci] Updated translations via Crowdin Fix "delete" modal dialog for issue/PR (go-gitea#27015) Fix context cache bug & enable context cache for dashabord commits' authors (go-gitea#26991) fix: typo (go-gitea#27009) Use secure cookie for HTTPS sites (go-gitea#26999) Add fetch wrappers, ignore network errors in actions view (go-gitea#26985)
Should BucketExists (HeadBucket) fail because of an error related to
the connection rather than the existence of the bucket, no information
is available and the admin is left guessing.
https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadBucket.html
GetBucketVersioning is used instead and exclusively dedicated to
asserting if using the connection does not return a BadRequest.
If it does the NewMinioStorage logs an error and returns. Otherwise
it keeps going knowing that BucketExists is not going to fail for
reasons unrelated to the existence of the bucket and the permissions
to access it.
(cherry picked from commit d1df4b3bc62e5e61893a923f1c4b58f084eb03af)
Refs: https://codeberg.org/forgejo/forgejo/issues/1338