[#191] Refactor error handling and logging #221

Merged
alexvanin merged 2 commits from dkirillov/frostfs-http-gw:bugfix/191-correct-status-codes into master 2025-03-25 06:27:57 +00:00
Member

close #191

close #191
dkirillov self-assigned this 2025-03-03 15:08:10 +00:00
dkirillov added 1 commit 2025-03-03 15:08:10 +00:00
[#191] Refactor error handling and logging
Some checks failed
/ DCO (pull_request) Successful in 36s
/ Builds (pull_request) Successful in 1m3s
/ Vulncheck (pull_request) Successful in 58s
/ OCI image (pull_request) Successful in 1m17s
/ Lint (pull_request) Failing after 1m26s
/ Tests (pull_request) Successful in 1m4s
/ Integration tests (pull_request) Failing after 5m32s
982ae32bc4
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
dkirillov force-pushed bugfix/191-correct-status-codes from 982ae32bc4 to 1796dfb6c1 2025-03-03 15:12:24 +00:00 Compare
dkirillov force-pushed bugfix/191-correct-status-codes from 1796dfb6c1 to d4eb7fe86e 2025-03-04 11:22:19 +00:00 Compare
dkirillov force-pushed bugfix/191-correct-status-codes from d4eb7fe86e to 224bc10667 2025-03-04 11:28:31 +00:00 Compare
requested review from storage-services-developers 2025-03-04 11:28:41 +00:00
dkirillov changed title from WIP: [#191] Refactor error handling and logging to [#191] Refactor error handling and logging 2025-03-04 11:28:45 +00:00
requested review from storage-services-committers 2025-03-04 11:28:45 +00:00
nzinkevich reviewed 2025-03-06 12:51:44 +00:00
@ -735,3 +735,3 @@
r.RedirectTrailingSlash = true
r.NotFound = func(r *fasthttp.RequestCtx) {
handler.ResponseError(r, "Not found", fasthttp.StatusNotFound)
handler.ResponseError(r, "Router Not found", fasthttp.StatusNotFound)
Member

Router -> Route

`Router` -> `Route`
dkirillov force-pushed bugfix/191-correct-status-codes from 224bc10667 to 75328dd934 2025-03-10 14:51:17 +00:00 Compare
r.loginov reviewed 2025-03-12 09:23:11 +00:00
docs/api.md Outdated
@ -320,0 +323,4 @@
| 400 | Some error occurred during object downloading. |
| 403 | Access denied. |
| 404 | Container or objects not found. |
| 409 | Can not upload object due to quota reached. |
Member

We can't seem to get a status of 409 when downloading the archive.

We can't seem to get a status of 409 when downloading the archive.
r.loginov marked this conversation as resolved
@ -86,3 +61,2 @@
func logAndSendBucketError(c *fasthttp.RequestCtx, log *zap.Logger, err error) {
log.Error(logs.CouldNotGetBucket, zap.Error(err), logs.TagField(logs.TagDatapath))
func (h *Handler) reqLogger(ctx context.Context) *zap.Logger {
Member

question: is this function intentionally not used here and here? It's just that if within the handler package we wrap the utils.GetReqLogOrDefault(ctx, h.log) function in reqLogger(ctx context.Context), don't we want to use it wherever possible?

question: is this function intentionally not used [here](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/commit/75328dd9340d5c1e4320ce95dc118b00f3a5b8c1/internal/handler/browse.go#L226) and [here](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/commit/75328dd9340d5c1e4320ce95dc118b00f3a5b8c1/internal/handler/browse.go#L261)? It's just that if within the handler package we wrap the `utils.GetReqLogOrDefault(ctx, h.log)` function in `reqLogger(ctx context.Context)`, don't we want to use it wherever possible?
Author
Member

Just missed that

Just missed that
r.loginov marked this conversation as resolved
@ -136,0 +104,4 @@
case errors.Is(err, layer.ErrNodeNotFound):
return fmt.Sprintf("Tree Node Not Found:\n%v", err), fasthttp.StatusNotFound
case errors.Is(err, ErrGatewayTimeout):
return fmt.Sprintf("Gateway Timeout:\n%v", err), fasthttp.StatusGatewayTimeout
Member

Should we also note in the API documentation the possibility of returning a 504 GatewayTimeout?

Should we also note in the API documentation the possibility of returning a 504 GatewayTimeout?
Author
Member

Then we probably should mention all codes (even this) for any endpoint 🤔

Then we probably should mention all codes (even [this](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/pulls/221#issuecomment-70101)) for any endpoint 🤔
Member

Regarding this - I was considering it from the point of view that we can catch quota overrun only when loading an object. And it seems that we can catch 504 in many places, but it is not mentioned in the documentation.

But I understand the idea, so let's leave it as it is now.

Regarding [this](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/pulls/221#issuecomment-70101) - I was considering it from the point of view that we can catch quota overrun only when loading an object. And it seems that we can catch 504 in many places, but it is not mentioned in the documentation. But I understand the idea, so let's leave it as it is now.
r.loginov marked this conversation as resolved
dkirillov force-pushed bugfix/191-correct-status-codes from 75328dd934 to 138d9ec1a8 2025-03-18 08:32:59 +00:00 Compare
alexvanin reviewed 2025-03-20 13:24:36 +00:00
@ -122,4 +132,2 @@
ObjectNotFound = "object not found"
ReadObjectListFailed = "read object list failed"
CouldNotStoreFileInFrostfs = "could not store file in frostfs"
FailedToHeadObject = "failed to head object"
Owner

You moved it to datapath section because those logs are produced in handler package?

You moved it to datapath section because those logs are produced in `handler` package?
Author
Member

Because it's error that I want to see if datapath request failed. Otherwise we don't understand much from logs

Because it's error that I want to see if datapath request failed. Otherwise we don't understand much from logs
alexvanin approved these changes 2025-03-20 13:34:30 +00:00
alexvanin left a comment
Owner

Overall LGTM

Overall LGTM
pogpp approved these changes 2025-03-20 14:14:25 +00:00
r.loginov approved these changes 2025-03-20 15:29:41 +00:00
alexvanin merged commit f0b86c8ba7 into master 2025-03-25 06:27:57 +00:00
alexvanin deleted branch bugfix/191-correct-status-codes 2025-03-25 06:28:11 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-http-gw#221
No description provided.