[#233] Clean tag node in the tree service instead of removal
All checks were successful
/ DCO (pull_request) Successful in 1m49s
/ Vulncheck (pull_request) Successful in 2m10s
/ Builds (1.20) (pull_request) Successful in 2m26s
/ Builds (1.21) (pull_request) Successful in 2m17s
/ Lint (pull_request) Successful in 4m21s
/ Tests (1.20) (pull_request) Successful in 2m15s
/ Tests (1.21) (pull_request) Successful in 2m10s
All checks were successful
/ DCO (pull_request) Successful in 1m49s
/ Vulncheck (pull_request) Successful in 2m10s
/ Builds (1.20) (pull_request) Successful in 2m26s
/ Builds (1.21) (pull_request) Successful in 2m17s
/ Lint (pull_request) Successful in 4m21s
/ Tests (1.20) (pull_request) Successful in 2m15s
/ Tests (1.21) (pull_request) Successful in 2m10s
With new retry policy of tree service pool, gateway should avoid deletion of system nodes from tree. Absence of node in the tree will trigger retry. Other storage in the network may return already deleted node while tree is not completely synced, and client will get unexpected result. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
5f9555afad
commit
e87c3715c5
2 changed files with 4 additions and 28 deletions
|
@ -49,14 +49,8 @@ func (t *TreeServiceMock) PutObjectTagging(_ context.Context, bktInfo *data.Buck
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TreeServiceMock) DeleteObjectTagging(_ context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error {
|
func (t *TreeServiceMock) DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error {
|
||||||
cnrTagsMap, ok := t.tags[bktInfo.CID.EncodeToString()]
|
return t.PutObjectTagging(ctx, bktInfo, objVersion, nil)
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(cnrTagsMap, objVersion.ID)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TreeServiceMock) GetBucketTagging(context.Context, *data.BucketInfo) (map[string]string, error) {
|
func (t *TreeServiceMock) GetBucketTagging(context.Context, *data.BucketInfo) (map[string]string, error) {
|
||||||
|
|
|
@ -471,16 +471,7 @@ func (c *Tree) PutObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, o
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Tree) DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error {
|
func (c *Tree) DeleteObjectTagging(ctx context.Context, bktInfo *data.BucketInfo, objVersion *data.NodeVersion) error {
|
||||||
tagNode, err := c.getTreeNode(ctx, bktInfo, objVersion.ID, isTagKV)
|
return c.PutObjectTagging(ctx, bktInfo, objVersion, nil)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if tagNode == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.service.RemoveNode(ctx, bktInfo, versionTree, tagNode.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Tree) GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error) {
|
func (c *Tree) GetBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) (map[string]string, error) {
|
||||||
|
@ -524,16 +515,7 @@ func (c *Tree) PutBucketTagging(ctx context.Context, bktInfo *data.BucketInfo, t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Tree) DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error {
|
func (c *Tree) DeleteBucketTagging(ctx context.Context, bktInfo *data.BucketInfo) error {
|
||||||
node, err := c.getSystemNode(ctx, bktInfo, []string{bucketTaggingFilename}, nil)
|
return c.PutBucketTagging(ctx, bktInfo, nil)
|
||||||
if err != nil && !errors.Is(err, layer.ErrNodeNotFound) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if node != nil {
|
|
||||||
return c.service.RemoveNode(ctx, bktInfo, systemTree, node.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Tree) getTreeNode(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64, key string) (*treeNode, error) {
|
func (c *Tree) getTreeNode(ctx context.Context, bktInfo *data.BucketInfo, nodeID uint64, key string) (*treeNode, error) {
|
||||||
|
|
Loading…
Reference in a new issue