forked from TrueCloudLab/frostfs-node
[#1402] ir: Collect SG from the object
Do not use `Marshal()` with object's payload. Use `ReadFromObject` func from SDK instead. That allows checking both attributes and SG body's expiration epoch. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
12d41918e6
commit
5f658c499c
1 changed files with 8 additions and 4 deletions
|
@ -80,6 +80,9 @@ func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.Ne
|
||||||
|
|
||||||
var info clientcore.NodeInfo
|
var info clientcore.NodeInfo
|
||||||
|
|
||||||
|
var getObjPrm neofsapiclient.GetObjectPrm
|
||||||
|
getObjPrm.SetAddress(addr)
|
||||||
|
|
||||||
for _, node := range placement.FlattenNodes(nodes) {
|
for _, node := range placement.FlattenNodes(nodes) {
|
||||||
err := clientcore.NodeInfoFromRawNetmapElement(&info, netmapcore.Node(node))
|
err := clientcore.NodeInfoFromRawNetmapElement(&info, netmapcore.Node(node))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -95,15 +98,16 @@ func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.Ne
|
||||||
}
|
}
|
||||||
|
|
||||||
cctx, cancel := context.WithTimeout(ctx, c.sgTimeout)
|
cctx, cancel := context.WithTimeout(ctx, c.sgTimeout)
|
||||||
|
getObjPrm.SetContext(cctx)
|
||||||
|
|
||||||
// NOTE: we use the function which does not verify object integrity (checksums, signature),
|
// NOTE: we use the function which does not verify object integrity (checksums, signature),
|
||||||
// but it would be useful to do as part of a data audit.
|
// but it would be useful to do as part of a data audit.
|
||||||
payload, err := neofsapiclient.GetObjectPayload(cctx, cli, addr)
|
res, err := cli.GetObject(getObjPrm)
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Warn("can't get payload of storage group object",
|
c.log.Warn("can't get storage group object",
|
||||||
zap.String("error", err.Error()))
|
zap.String("error", err.Error()))
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
@ -111,9 +115,9 @@ func (c *ClientCache) getSG(ctx context.Context, addr oid.Address, nm *netmap.Ne
|
||||||
|
|
||||||
var sg storagegroup.StorageGroup
|
var sg storagegroup.StorageGroup
|
||||||
|
|
||||||
err = sg.Unmarshal(payload)
|
err = storagegroup.ReadFromObject(&sg, *res.Object())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't parse storage group payload: %w", err)
|
return nil, fmt.Errorf("can't parse storage group from a object: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &sg, nil
|
return &sg, nil
|
||||||
|
|
Loading…
Reference in a new issue