Skip to content

services/object: use SearchV2 for search objects #3312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Changelog for NeoFS Node
- Storage Nodes do not accept REPLICATE with a header that exceeds the limit (#3297)
- Search API is served from SearchV2 indexes now (#3316)
- Blobstor can be of exactly one type, with no substorages (#3330)
- SN uses SearchV2 to verify tombstones (#3312)

### Removed
- SN `apiclient.allow_external` config (#3235)
Expand Down
51 changes: 29 additions & 22 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
objectSDK "github.com/nspcc-dev/neofs-sdk-go/object"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
protoobject "github.com/nspcc-dev/neofs-sdk-go/proto/object"
protosession "github.com/nspcc-dev/neofs-sdk-go/proto/session"
apireputation "github.com/nspcc-dev/neofs-sdk-go/reputation"
"github.com/nspcc-dev/neofs-sdk-go/user"
"github.com/nspcc-dev/neofs-sdk-go/version"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -244,6 +246,7 @@
mNumber, err := c.shared.basics.cli.MagicNumber()
fatalOnErr(err)

os := &objectSource{get: sGet}

Check warning on line 249 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L249

Added line #L249 was not covered by tests
sPut := putsvc.NewService(&transport{clients: putConstructor}, c,
putsvc.WithNetworkMagic(mNumber),
putsvc.WithKeyStorage(keyStorage),
Expand All @@ -257,7 +260,7 @@
putsvc.WithWorkerPools(c.cfgObject.pool.putRemote, c.cfgObject.pool.putLocal),
putsvc.WithLogger(c.log),
putsvc.WithSplitChainVerifier(split.NewVerifier(sGet)),
putsvc.WithTombstoneVerifier(tombstone.NewVerifier(objectSource{sGet, sSearch})),
putsvc.WithTombstoneVerifier(tombstone.NewVerifier(os)),

Check warning on line 263 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L263

Added line #L263 was not covered by tests
)

sDelete := deletesvc.New(
Expand Down Expand Up @@ -314,6 +317,7 @@
keys: keyStorage,
}
server := objectService.New(objSvc, mNumber, fsChain, storage, c.metaService, c.shared.basics.key.PrivateKey, c.metricsCollector, aclChecker, aclSvc, coreConstructor)
os.server = server

Check warning on line 320 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L320

Added line #L320 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems racy, os is already given to the tombstone.NewVerifier(). Not sure there are any threads involved though, maybe not a problem.


for _, srv := range c.cfgGRPC.servers {
protoobject.RegisterObjectServiceServer(srv, server)
Expand Down Expand Up @@ -639,16 +643,9 @@

type objectSource struct {
get *getsvc.Service
search *searchsvc.Service
}

type searchWriter struct {
ids []oid.ID
}

func (w *searchWriter) WriteIDs(ids []oid.ID) error {
w.ids = append(w.ids, ids...)
return nil
server interface {
ProcessSearch(ctx context.Context, req *protoobject.SearchV2Request) ([]client.SearchResultItem, []byte, error)
}
}

func (o objectSource) Head(ctx context.Context, addr oid.Address) (*objectSDK.Object, error) {
Expand All @@ -664,20 +661,30 @@
return hw.h, err
}

func (o objectSource) Search(ctx context.Context, cnr cid.ID, filters objectSDK.SearchFilters) ([]oid.ID, error) {
var sw searchWriter

var sPrm searchsvc.Prm
sPrm.SetWriter(&sw)
sPrm.WithSearchFilters(filters)
sPrm.WithContainerID(cnr)

err := o.search.Search(ctx, sPrm)
func (o objectSource) SearchOne(ctx context.Context, cnr cid.ID, filters objectSDK.SearchFilters) (oid.ID, error) {
var id oid.ID
res, _, err := o.server.ProcessSearch(ctx, &protoobject.SearchV2Request{
Body: &protoobject.SearchV2Request_Body{
ContainerId: cnr.ProtoMessage(),
Version: 1,
Filters: filters.ProtoMessage(),
Cursor: "",
Count: 1,
Attributes: nil,
},
MetaHeader: &protosession.RequestMetaHeader{
Version: version.Current().ProtoMessage(),
Ttl: 2,
},
})

Check warning on line 679 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L664-L679

Added lines #L664 - L679 were not covered by tests
if err != nil {
return nil, err
return id, err

Check warning on line 681 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L681

Added line #L681 was not covered by tests
}

return sw.ids, nil
if len(res) == 1 {
return res[0].ID, nil
}
return id, nil

Check warning on line 687 in cmd/neofs-node/object.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-node/object.go#L684-L687

Added lines #L684 - L687 were not covered by tests
}

// IsLocalNodePublicKey checks whether given binary-encoded public key is
Expand Down
Loading
Loading