[SUPPORT]: Ignore ECInfoErr erros in GetSplitInfo #313

Merged
fyrchik merged 1 commit from aarifullin/frostfs-sdk-go:fix/ignore_ec_info_err into support/v1.0.0-rc.5 2024-12-12 07:12:50 +00:00
Member
  • Ignore ECInfoError errors after raw HeadObject request in GetSplitInfo

Close #312

* Ignore `ECInfoError` errors after raw `HeadObject` request in `GetSplitInfo` Close #312
aarifullin added the
pool
label 2024-12-11 15:27:20 +00:00
aarifullin added 1 commit 2024-12-11 15:27:21 +00:00
[#312] pool: Ignore ECInfoErr erros in GetSplitInfo
All checks were successful
DCO / DCO (pull_request) Successful in 1m47s
Tests and linters / Tests (pull_request) Successful in 2m1s
Tests and linters / Lint (pull_request) Successful in 2m44s
015f6e3891
* Ignore `ECInfoError` errors after raw `HeadObject` request

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
aarifullin added the
bug
label 2024-12-11 15:27:30 +00:00
aarifullin changed title from Ignore ECInfoErr erros in GetSplitInfo to SUPPORT: Ignore ECInfoErr erros in GetSplitInfo 2024-12-11 15:27:36 +00:00
aarifullin changed title from SUPPORT: Ignore ECInfoErr erros in GetSplitInfo to [SUPPORT]: Ignore ECInfoErr erros in GetSplitInfo 2024-12-11 15:27:49 +00:00
aarifullin requested review from storage-core-committers 2024-12-11 15:28:00 +00:00
aarifullin requested review from storage-core-developers 2024-12-11 15:28:02 +00:00
aarifullin requested review from storage-services-committers 2024-12-11 15:28:18 +00:00
aarifullin requested review from storage-services-developers 2024-12-11 15:28:19 +00:00
alexvanin approved these changes 2024-12-11 15:49:50 +00:00
elebedeva approved these changes 2024-12-11 16:01:10 +00:00
@ -2990,3 +2991,3 @@
case errors.As(err, &errSplit):
return errSplit.SplitInfo(), nil
case err == nil:
case err == nil || errors.As(err, &errECInfo):
Member

Why using errors.As() here and not errors.Is()?

Why using `errors.As()` here and not `errors.Is()`?
Owner

errors.Is checks exact error value (similar to == check) while errors.As tries to cast error to error type.

Exact value check is being used when error is explicitly defined (e.g. MyError := errors.New("my error").

returnedError := object.NewECInfoError(&object.ECInfo{
	Chunks: []v2object.ECChunk{{Index: 1, Total: 2}},
})

// Try to check error
var errECInfo *object.ECInfoError
fmt.Println(errors.Is(returnedError, errECInfo))  // false
fmt.Println(errors.As(returnedError, &errECInfo)) // true
`errors.Is` checks exact error value (similar to `==` check) while `errors.As` tries to cast error to error type. Exact value check is being used when error is explicitly defined (e.g. `MyError := errors.New("my error"`). ```go returnedError := object.NewECInfoError(&object.ECInfo{ Chunks: []v2object.ECChunk{{Index: 1, Total: 2}}, }) // Try to check error var errECInfo *object.ECInfoError fmt.Println(errors.Is(returnedError, errECInfo)) // false fmt.Println(errors.As(returnedError, &errECInfo)) // true ```
Author
Member

@alexvanin is right.
errors.Is would have been used if var errECInfo = errors.New("object not found, ec info provided"), but it's introduced as complex type with data within

@alexvanin is right. `errors.Is` would have been used if `var errECInfo = errors.New("object not found, ec info provided")`, but it's introduced as complex type with data within
elebedeva marked this conversation as resolved
Owner

Does this PR close any issue?

Does this PR close any issue?
dkirillov approved these changes 2024-12-12 06:28:02 +00:00
Author
Member

Does this PR close any issue?

Oh, fixed the description. I'll also open PR for master

> Does this PR close any issue? Oh, fixed the description. I'll also open PR for master
fyrchik merged commit 015f6e3891 into support/v1.0.0-rc.5 2024-12-12 07:12:50 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-committers
TrueCloudLab/storage-services-developers
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-sdk-go#313
No description provided.