Fix access denied error handling for GET requests support/v0.42 #1339
3 changed files with 29 additions and 12 deletions
|
@ -2,9 +2,11 @@ package getsvc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||||
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -120,6 +122,12 @@ func (exec *request) analyzeStatus(ctx context.Context, execCnr bool) {
|
||||||
exec.log.Debug(logs.OperationFinishedWithError,
|
exec.log.Debug(logs.OperationFinishedWithError,
|
||||||
zap.Error(exec.err),
|
zap.Error(exec.err),
|
||||||
)
|
)
|
||||||
|
var errAccessDenied *apistatus.ObjectAccessDenied
|
||||||
|
if execCnr && errors.As(exec.err, &errAccessDenied) {
|
||||||
|
// Local get can't return access denied error, so this error was returned by
|
||||||
|
// write to the output stream. So there is no need to try to find object on other nodes.
|
||||||
fyrchik marked this conversation as resolved
|
|||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if execCnr {
|
if execCnr {
|
||||||
exec.executeOnContainer(ctx)
|
exec.executeOnContainer(ctx)
|
||||||
|
|
|
@ -31,6 +31,7 @@ func (r *request) processNode(ctx context.Context, info client.NodeInfo) bool {
|
||||||
var errECInfo *objectSDK.ECInfoError
|
var errECInfo *objectSDK.ECInfoError
|
||||||
var errRemoved *apistatus.ObjectAlreadyRemoved
|
var errRemoved *apistatus.ObjectAlreadyRemoved
|
||||||
var errOutOfRange *apistatus.ObjectOutOfRange
|
var errOutOfRange *apistatus.ObjectOutOfRange
|
||||||
|
var errAccessDenied *apistatus.ObjectAccessDenied
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
default:
|
default:
|
||||||
|
@ -38,7 +39,11 @@ func (r *request) processNode(ctx context.Context, info client.NodeInfo) bool {
|
||||||
if r.status != statusEC {
|
if r.status != statusEC {
|
||||||
// for raw requests, continue to collect other parts
|
// for raw requests, continue to collect other parts
|
||||||
r.status = statusUndefined
|
r.status = statusUndefined
|
||||||
r.err = new(apistatus.ObjectNotFound)
|
if errors.As(err, &errAccessDenied) {
|
||||||
fyrchik marked this conversation as resolved
fyrchik
commented
Why is it in the default branch, instead of being similar to other status errors? Why is it in the default branch, instead of being similar to other status errors?
dstepanov-yadro
commented
Because i think it is a part of default branch: default branch continues iteration (returns false) Because i think it is a part of default branch: default branch continues iteration (returns false)
|
|||||||
|
r.err = err
|
||||||
|
} else {
|
||||||
|
r.err = new(apistatus.ObjectNotFound)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
case err == nil:
|
case err == nil:
|
||||||
|
|
|
@ -23,12 +23,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type getRequestForwarder struct {
|
type getRequestForwarder struct {
|
||||||
OnceResign sync.Once
|
OnceResign sync.Once
|
||||||
OnceHeaderSending sync.Once
|
GlobalProgress int
|
||||||
GlobalProgress int
|
Key *ecdsa.PrivateKey
|
||||||
Key *ecdsa.PrivateKey
|
Request *objectV2.GetRequest
|
||||||
Request *objectV2.GetRequest
|
Stream *streamObjectWriter
|
||||||
Stream *streamObjectWriter
|
|
||||||
|
headerSent bool
|
||||||
|
headerSentGuard sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *getRequestForwarder) forwardRequestToNode(ctx context.Context, addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
|
func (f *getRequestForwarder) forwardRequestToNode(ctx context.Context, addr network.Address, c client.MultiAddressClient, pubkey []byte) (*objectSDK.Object, error) {
|
||||||
|
@ -83,13 +85,15 @@ func (f *getRequestForwarder) writeHeader(ctx context.Context, v *objectV2.GetOb
|
||||||
obj.SetSignature(v.GetSignature())
|
obj.SetSignature(v.GetSignature())
|
||||||
obj.SetHeader(v.GetHeader())
|
obj.SetHeader(v.GetHeader())
|
||||||
|
|
||||||
var err error
|
f.headerSentGuard.Lock()
|
||||||
f.OnceHeaderSending.Do(func() {
|
defer f.headerSentGuard.Unlock()
|
||||||
err = f.Stream.WriteHeader(ctx, objectSDK.NewFromV2(obj))
|
if f.headerSent {
|
||||||
})
|
return nil
|
||||||
if err != nil {
|
}
|
||||||
|
if err := f.Stream.WriteHeader(ctx, objectSDK.NewFromV2(obj)); err != nil {
|
||||||
return errCouldNotWriteObjHeader(err)
|
return errCouldNotWriteObjHeader(err)
|
||||||
}
|
}
|
||||||
|
f.headerSent = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue
How can we get this error while returning the result?
APE check for GET request performed on header send to check object headers.