[#239] pool/tree: Update tree service client
Update tree service to fix split tree problem. Tree intermediate nodes can be duplicated so we must handle this. Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
e18b916231
commit
7c06cdff2d
9 changed files with 37 additions and 59 deletions
2
go.mod
2
go.mod
|
@ -5,7 +5,6 @@ go 1.21
|
||||||
require (
|
require (
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240530152826-2f6d3209e1d3
|
git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240530152826-2f6d3209e1d3
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-contract v0.19.3
|
git.frostfs.info/TrueCloudLab/frostfs-contract v0.19.3
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
|
|
||||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
git.frostfs.info/TrueCloudLab/hrw v1.2.1
|
||||||
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
git.frostfs.info/TrueCloudLab/tzhash v1.8.0
|
||||||
github.com/antlr4-go/antlr/v4 v4.13.0
|
github.com/antlr4-go/antlr/v4 v4.13.0
|
||||||
|
@ -22,6 +21,7 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 // indirect
|
||||||
git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0 // indirect
|
git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||||
|
|
|
@ -126,7 +126,7 @@ type GetNodesParams struct {
|
||||||
type GetSubTreeParams struct {
|
type GetSubTreeParams struct {
|
||||||
CID cid.ID
|
CID cid.ID
|
||||||
TreeID string
|
TreeID string
|
||||||
RootID uint64
|
RootID []uint64
|
||||||
Depth uint32
|
Depth uint32
|
||||||
BearerToken []byte
|
BearerToken []byte
|
||||||
Order SubTreeSort
|
Order SubTreeSort
|
||||||
|
@ -308,12 +308,7 @@ func (p *Pool) GetNodes(ctx context.Context, prm GetNodesParams) ([]*grpcService
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,12 +405,7 @@ func (p *Pool) GetSubTree(ctx context.Context, prm GetSubTreeParams) (*SubTreeRe
|
||||||
request.Body.OrderBy.Direction = grpcService.GetSubTreeRequest_Body_Order_None
|
request.Body.OrderBy.Direction = grpcService.GetSubTreeRequest_Body_Order_None
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,12 +435,7 @@ func (p *Pool) AddNode(ctx context.Context, prm AddNodeParams) (uint64, error) {
|
||||||
BearerToken: prm.BearerToken,
|
BearerToken: prm.BearerToken,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,12 +467,7 @@ func (p *Pool) AddNodeByPath(ctx context.Context, prm AddNodeByPathParams) (uint
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,12 +507,7 @@ func (p *Pool) MoveNode(ctx context.Context, prm MoveNodeParams) error {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,12 +533,7 @@ func (p *Pool) RemoveNode(ctx context.Context, prm RemoveNodeParams) error {
|
||||||
BearerToken: prm.BearerToken,
|
BearerToken: prm.BearerToken,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := p.signRequest(request.Body, func(key, sign []byte) {
|
if err := p.signRequest(request); err != nil {
|
||||||
request.Signature = &grpcService.Signature{
|
|
||||||
Key: key,
|
|
||||||
Sign: sign,
|
|
||||||
}
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,38 @@
|
||||||
package tree
|
package tree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
crypto "git.frostfs.info/TrueCloudLab/frostfs-crypto"
|
frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
|
||||||
"google.golang.org/protobuf/proto"
|
tree "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Pool) signData(buf []byte, f func(key, sign []byte)) error {
|
type message interface {
|
||||||
sign, err := crypto.Sign(&p.key.PrivateKey, buf)
|
SignedDataSize() int
|
||||||
|
ReadSignedData([]byte) ([]byte, error)
|
||||||
|
GetSignature() *tree.Signature
|
||||||
|
SetSignature(*tree.Signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
// signMessage uses the pool key and signs any protobuf
|
||||||
|
// message that was generated for the TreeService by the
|
||||||
|
// protoc-gen-go-frostfs generator. Returns any errors directly.
|
||||||
|
func (p *Pool) signRequest(m message) error {
|
||||||
|
binBody, err := m.ReadSignedData(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
f(p.key.PublicKey().Bytes(), sign)
|
keySDK := frostfsecdsa.Signer(p.key.PrivateKey)
|
||||||
|
data, err := keySDK.Sign(binBody)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rawPub := make([]byte, keySDK.Public().MaxEncodedSize())
|
||||||
|
rawPub = rawPub[:keySDK.Public().Encode(rawPub)]
|
||||||
|
m.SetSignature(&tree.Signature{
|
||||||
|
Key: rawPub,
|
||||||
|
Sign: data,
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Pool) signRequest(requestBody proto.Message, f func(key, sign []byte)) error {
|
|
||||||
buf, err := proto.Marshal(requestBody)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return p.signData(buf, f)
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
BIN
pool/tree/service/service_frostfs.pb.go
Normal file
BIN
pool/tree/service/service_frostfs.pb.go
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
pool/tree/service/types_frostfs.pb.go
Normal file
BIN
pool/tree/service/types_frostfs.pb.go
Normal file
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
REVISION="b3695411d907c3c65485bab04f9ff8479a72906b"
|
REVISION="00a88b99368d7141380f65d9cb446f1e4771ba01"
|
||||||
|
|
||||||
echo "tree service revision ${REVISION}"
|
echo "tree service revision ${REVISION}"
|
||||||
|
|
||||||
|
@ -9,11 +9,6 @@ echo "tree service revision ${REVISION}"
|
||||||
FILES=$(curl -s https://git.frostfs.info/TrueCloudLab/frostfs-node/src/commit/${REVISION}/pkg/services/tree | sed -n "s,.*\"/TrueCloudLab/frostfs-node/src/commit/${REVISION}/pkg/services/tree/\([^.]*\.pb\.go\)\".*,\1,p")
|
FILES=$(curl -s https://git.frostfs.info/TrueCloudLab/frostfs-node/src/commit/${REVISION}/pkg/services/tree | sed -n "s,.*\"/TrueCloudLab/frostfs-node/src/commit/${REVISION}/pkg/services/tree/\([^.]*\.pb\.go\)\".*,\1,p")
|
||||||
|
|
||||||
for file in $FILES; do
|
for file in $FILES; do
|
||||||
if [[ $file == *"frostfs"* ]]; then
|
echo "sync '$file' in tree service"
|
||||||
echo "skip '$file'"
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
echo "sync '$file' in tree service"
|
|
||||||
fi
|
|
||||||
curl -s "https://git.frostfs.info/TrueCloudLab/frostfs-node/raw/commit/${REVISION}/pkg/services/tree/${file}" -o "./pool/tree/service/${file}"
|
curl -s "https://git.frostfs.info/TrueCloudLab/frostfs-node/raw/commit/${REVISION}/pkg/services/tree/${file}" -o "./pool/tree/service/${file}"
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue