[#9999] object: Fix IO tag adjustment for Put/Patch

There was no tag adjustment for CloseAndRecv.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2025-02-10 17:55:34 +03:00
parent 2d4749c73a
commit f380fcafee
Signed by: dstepanov-yadro
GPG key ID: 237AF1A763293BC0

View file

@ -3,6 +3,8 @@ package object
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/assert"
"git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
)
@ -120,13 +122,24 @@ type qosSendRecv[TReq qosVerificationHeader, TResp any] interface {
type qosWriteStream[TReq qosVerificationHeader, TResp any] struct {
s qosSendRecv[TReq, TResp]
adj AdjustIOTag
ioTag string
ioTagDefined bool
}
func (q *qosWriteStream[TReq, TResp]) CloseAndRecv(ctx context.Context) (TResp, error) {
if q.ioTagDefined {
ctx = tagging.ContextWithIOTag(ctx, q.ioTag)
}
return q.s.CloseAndRecv(ctx)
}
func (q *qosWriteStream[TReq, TResp]) Send(ctx context.Context, req TReq) error {
ctx = q.adj.AdjustIncomingTag(ctx, req.GetVerificationHeader().GetBodySignature().GetKey())
if !q.ioTagDefined {
ctx = q.adj.AdjustIncomingTag(ctx, req.GetVerificationHeader().GetBodySignature().GetKey())
q.ioTag, q.ioTagDefined = tagging.IOTagFromContext(ctx)
}
assert.Cond(q.ioTagDefined, "io tag undefined after incoming tag adjustment")
ctx = tagging.ContextWithIOTag(ctx, q.ioTag)
return q.s.Send(ctx, req)
}