forked from TrueCloudLab/frostfs-s3-gw
[#125] Added exact eacl checking
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
e78543adf3
commit
acc2cdd96c
1 changed files with 14 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
package layer
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"fmt"
|
||||
|
@ -165,7 +166,7 @@ func (n *layer) setContainerEACL(ctx context.Context, cid *cid.ID, gateKey *keys
|
|||
return err
|
||||
}
|
||||
|
||||
if err := n.waitEACLPresence(ctx, cid, defaultWaitParams()); err != nil {
|
||||
if err := n.waitEACLPresence(ctx, cid, table, defaultWaitParams()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -205,7 +206,12 @@ func defaultWaitParams() *waitParams {
|
|||
}
|
||||
}
|
||||
|
||||
func (n *layer) waitEACLPresence(ctx context.Context, cid *cid.ID, params *waitParams) error {
|
||||
func (n *layer) waitEACLPresence(ctx context.Context, cid *cid.ID, table *eacl.Table, params *waitParams) error {
|
||||
exp, err := table.Marshal()
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't marshal eacl: %w", err)
|
||||
}
|
||||
|
||||
wctx, cancel := context.WithTimeout(ctx, params.WaitTimeout)
|
||||
defer cancel()
|
||||
ticker := time.NewTimer(params.PollInterval)
|
||||
|
@ -219,8 +225,12 @@ func (n *layer) waitEACLPresence(ctx context.Context, cid *cid.ID, params *waitP
|
|||
case <-wdone:
|
||||
return wctx.Err()
|
||||
case <-ticker.C:
|
||||
if _, err := n.pool.GetEACL(ctx, cid); err == nil {
|
||||
return nil
|
||||
signedEacl, err := n.pool.GetEACL(ctx, cid)
|
||||
if err == nil {
|
||||
got, err := signedEacl.EACL().Marshal()
|
||||
if err == nil && bytes.Equal(exp, got) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
ticker.Reset(params.PollInterval)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue